/* $OpenBSD: pthread_test.c,v 1.4 2003/07/31 21:48:05 deraadt Exp $ */ /* PUBLIC DOMAIN Oct 2002 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void * run_thread1 (void *arg) { printf ("Starting THREAD1\n"); while (1) { sleep(4); printf ("THREAD1 is going back to sleep\n"); } } void * run_thread2 (void *arg) { printf ("Starting THREAD2\n"); while (1) { sleep(4); printf ("THREAD2 is going back to sleep\n"); } } int main (int argc, char **argv) { int i; pthread_t thread1; pthread_t thread2; pthread_create (&thread1, NULL, run_thread1, NULL); pthread_create (&thread2, NULL, run_thread2, NULL); sleep (1); while (1) { sleep(4); printf ("Main thread is going back to sleep\n"); } }