main-threaded.c revision 1e8f6fe9680c994b9c86753c3345a4579f726fc4
1#include <pthread.h> 2 3extern void print (char *); 4 5#define PRINT_LOOP 10 6 7void * 8th_main (void *arg) 9{ 10 int i; 11 for (i=0; i<PRINT_LOOP; i++) 12 print (arg); 13} 14 15int 16main () 17{ 18 pthread_t thread1; 19 pthread_t thread2; 20 pthread_t thread3; 21 pthread_create (&thread1, NULL, th_main, "aaa"); 22 pthread_create (&thread2, NULL, th_main, "bbb"); 23 pthread_create (&thread3, NULL, th_main, "ccc"); 24 pthread_join (thread1, NULL); 25 pthread_join (thread2, NULL); 26 pthread_join (thread3, NULL); 27 return 0; 28} 29 30