#include #include int counter=0; void threadedFunction(void *ptr){ int i; for (i=0; i<10; i++) { printf("hello from %s (counter=%d)\n",(char*) ptr,counter++); sleep(1); } } int main(int argc, char** argv) { pthread_t thread1, thread2; int iret1, iret2; iret1 = pthread_create( &thread1, NULL, (void*)&threadedFunction, (void*) "thread 1"); iret2 = pthread_create( &thread2, NULL, (void*)&threadedFunction, (void*) "thread 2"); pthread_join( thread1, NULL); pthread_join( thread2, NULL); printf("thread 1 returns: %d\n",iret1); printf("thread 2 returns: %d\n",iret2); exit(0); }