#include #include #include void *slowthread(void *i) { int j=0; while(++j < 15){ //print Hi once every 5 seconds usleep(2000000); printf("Hi %d from slowthread\n",j);} } void *fastthread(void *i) { int j=0; //print Hi once every 1 second while(++j < 15){ usleep(500000); printf("Hi %d from fastthread\n",j);} } main() { pthread_t thread,thread2; int dummy; pthread_create(&thread,NULL,slowthread, (void *) &dummy); pthread_create(&thread2,NULL,fastthread,(void *)&dummy); //fastthread((void *) &dummy); //wait for other thread to finish pthread_join(thread,NULL); pthread_join(thread2,NULL); pthread_exit(NULL); }