/****************************************************************************** * FILE: bug5.c * DESCRIPTION: * A simple pthreads program that dies before the threads can do their * work. Figure out why. * AUTHOR: 07/06/05 Blaise Barney * LAST REVISED: 07/11/12 ******************************************************************************/ #include #include #include #include #define NUM_THREADS 5 void *PrintHello(void *threadid) { int i; double myresult=0.0; printf("thread=%ld: starting...\n", threadid); for (i=0; i<1000000; i++) myresult += sin(i) * tan(i); printf("thread=%ld result=%e. Done.\n",threadid,myresult); pthread_exit(NULL); } int main(int argc, char *argv[]) { pthread_t threads[NUM_THREADS]; int rc; long t; for(t=0;t