Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<pthread.h>
- void* say_hello(void* data)
- {
- char *str;
- str = (char*)data;
- printf("%s\n",str);
- }
- void main()
- {
- pthread_t t1, t2, t3, t4;
- int childpid;
- childpid = fork();
- if (childpid == 0) {
- pthread_create(&t1,NULL,say_hello, "First thread from parent process");
- pthread_create(&t2,NULL,say_hello, "Second thread from parent process");
- }
- else {
- pthread_create(&t3,NULL,say_hello,"First thread from child process");
- pthread_create(&t4,NULL,say_hello,"Second thread from child process");
- }
- waitpid(childpid, NULL, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement