/****************************************************************************** * FILE: minim2.c * DESCRIPTION: * This is a very minimal program using Pthreads. The main function * creates 4 threads. Each thread executes a function which prints out the * thread "number". Creation of a joinable thread is demonstrated by using * the appropriate attributes when creating the thread. * * SOURCE: Vijay Sonnad, IBM * LAST REVISED: 9/20/98 Blaise Barney ******************************************************************************/ #include #include #define NUMTHDS 4 void *thrdfun (void *arg); int main(int argc, char *argv[]) { /* We define an array of thread identifiers which are later used in the call to create threads. */ pthread_t thrdid[NUMTHDS]; pthread_attr_t attr; int status,i; /* Create attribute of JOINABLE for use in creating threads */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); /* Create threads using the attribute */ for (i=0; i