Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <pthread.h>
- #include <sys/neutrino.h>
- pthread_t thread_id1;
- pthread_t thread_id2;
- void * long_thread1(void *notused)
- {
- int n;
- for(n=0; n<5; n++)
- {
- printf("This is first thread, TID %d, N repeat %d \n", thread_id1, n);
- sleep(2);
- }
- }
- void * long_thread2(void *notused)
- {
- int m;
- for(m=0; m<5; m++)
- {printf("This is second thread, TID %d, N repeat %d \n", thread_id2, m);
- sleep(1);
- }
- }
- int main(void)
- {
- printf("Parent PID = %d\n", getpid());
- pthread_create(&thread_id1, NULL, long_thread1, NULL);
- pthread_create(&thread_id2, NULL, long_thread2, NULL);
- sleep(20);
- return(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement