Subj : Re: how to use select in each thread To : comp.programming.threads From : David Schwartz Date : Sun Apr 17 2005 12:21 pm "Zongjun Qi" wrote in message news:1113752441.212584.168120@o13g2000cwo.googlegroups.com... > struct timeval tv; > tv.tv_sec= 0; > tv.tv_usec=100000*(threadnumber+1); > while(1) > { > select(0,NULL,NULL,NULL,&tv); > printf("Thread number=%d\n", threadnumber); > } > } This is the clasic 'select' bug. You need to set up the parameters *each* time you call 'select', not just the first time. Otherwise, you're calling 'select' the second time with whatever junk was leftover from the first call. Try this: while(1) { struct timeval tv2=tv; select(0,NULL,NULL,NULL,&tv2); printf(... } .