#include #include #include #include #include #include void* run (void* arg){ sleep(10-(int)arg); printf("Hello from run\n"); } int main(){ pthread_t thread[10]; int i = 0; for (i = 0 ; i < 10; ++i) pthread_create(&thread[i], NULL, &run,(void*)i); // If you plan to use the results of all the threads, consider // using join for all of the threads for (i = 0 ; i < 10; ++i) pthread_join(thread[i],NULL); printf("In main"); }