#include #include #include void *thread_func( void *vptr_args ); void l(); int i,j,x = 0; int main( void ){ fprintf( stdout, "Why did the multithreaded chicken cross the road?\n"); char* answer[6] = {"To", "get", "to", "the", "other", "side"}; pthread_t threads[6]; for(j=0;j<6;j++) { pthread_create( &threads[j], NULL, &thread_func, (void *) answer[j]); } for(i=0;i<6;) { pthread_join( threads[i], NULL ); usleep(10000); } exit( EXIT_SUCCESS ); } void l(){for(x=0;x<=5000000;x++);} void *thread_func( void *vptr_args ){ i++; l(); fprintf( stdout,"%s ", (char*) vptr_args ); l(); pthread_exit( NULL ); }