#include <stdio.h> #include <pthread.h> #include <stdlib.h> static int global = 0; void* work(void *args) { int working = *(int *) args; for (int i = 0; i < 10; i++) { printf("%d from t%d\n", global++, working); } return NULL; } int main() { pthread_t tid1, tid2; int t1 = 1; int t2 = 2; pthread_create(&tid1, 0, work, &t1); pthread_create(&tid2, 0, work, &t2); pthread_join(tid1, NULL); pthread_join(tid2, NULL); return 0; }