#include #include #include typedef struct thread_args{ char letter; int id; }Args; void* run (void* arg){ Args* argg = (Args*) arg; int i = argg->id; printf("Hello from run %d\n", i); return NULL; } int main(int argc, char** argv){ pthread_t thread[10]; int i = 0; for (i = 0 ; i < 10; i++){ Args* argg = (Args*) (malloc(sizeof(Args))); argg->letter = 'q'; argg->id = i; pthread_create(&(thread[i]), NULL, &run,(void*)argg); } for (i = 0 ; i < 10; i++){ pthread_join(thread[i],NULL); } // Free the resources somewhere, for long running program. Or let the OS handle that printf("In main"); return 0; }