#include #include #include #include "pthread.h" int count = 0; void * process(void * arg) { int i; for (i = 0; i < 10; i++) { printf("Thread %u: String is %s and count is %d\n", getpid(), arg, count++); sleep(rand() % 2); } return NULL; } int main(void) { int retcode; pthread_t thread1, thread2; void * retval; printf("Calling process ID is %d\n", getpid()); if (fork() == 0) { process(( void *) "aaaa"); return 0; } if (fork() == 0) { process( (void *) "bbbb"); return 0; } process( (void *) "cccc"); wait(); wait(); return 0; }