Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <pthread.h>
  3.  
  4. static int flag;
  5.  
  6. void func1(void)
  7. {
  8.   flag = 0;
  9.   while(flag)
  10.   {
  11.     printf("YOBA\n");  
  12.   }
  13. }
  14.  
  15. void *func2(void *unused)
  16. {
  17.   printf("THR STARTED\n");
  18.   flag = 1;
  19.   for(;;);
  20. }
  21.  
  22. int main()
  23. {
  24.   pthread_t thr;
  25.   pthread_create(&thr, NULL, func2, NULL);
  26.   func1();
  27.   for (;;);
  28.   return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement