Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <pthread.h>
  3.  
  4. void *fun1();
  5. void *fun2();
  6. void *fun3();
  7.  
  8.  
  9. int A = 50;
  10. int B = 20;
  11. int C = 40;
  12. int D = 23;
  13. int E = 12;
  14. int F = 22;
  15.  
  16. int AB=0;
  17. int CD=0;
  18. int EF=0;
  19.  
  20. int main(){
  21. pthread_t thread1, thread2, thread3;
  22.  
  23. int R = 0;
  24.  
  25. pthread_create(&thread1, NULL, &fun1, NULL);
  26. pthread_create(&thread2, NULL, &fun2, NULL);
  27. pthread_create(&thread3, NULL, &fun3, NULL);
  28.  
  29. pthread_join(thread1, NULL);
  30. pthread_join(thread2, NULL);
  31. pthread_join(thread3, NULL);
  32.  
  33.  
  34. R = AB*CD*EF;
  35.  
  36.  
  37. printf("Konec, Rezultat = %d \n", R);
  38.  
  39.  
  40.  
  41. return 0;
  42. }
  43.  
  44. void *fun1(){
  45. AB = A+B;
  46.  
  47. }
  48.  
  49. void *fun2(){
  50. CD =C-D;
  51.  
  52. }
  53.  
  54. void *fun3(){
  55. EF = E+F;
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement