Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unistd.h>
- #include <pthread.h>
- void* T(char* cptr){
- sleep(1), write(1,cptr,1), *cptr = 'a';
- }
- int main() {
- char c = 's';
- int p = fork();
- if(p == 0){
- int tid; pthread_create(&tid, 0, T, &c);
- write(1,&c,1);
- c = 'p', pthread_join(tid,0);
- write(1, &c, 1);
- }else{
- p = fork();
- if(p ==0){
- write(1,&c,1);
- }else{
- write(1,&c,1);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement