Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <pthread.h>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int i = 0;
  7.  
  8. void *scrivi(void *parametro)
  9. {
  10.     while(i<=10){
  11.         usleep(100000);
  12.         cout<<"Ho scritto "<<i++<<endl;
  13.         usleep(900000);
  14.     }
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20.    pthread_t tid;
  21.    pthread_create(&tid, 0, scrivi, 0);
  22.    while(i<=10){
  23.        cout << "Letto "<<i<<endl;
  24.        sleep(1);
  25.    }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement