Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public string Get()
  2. {
  3. string current_variable = "";
  4.  
  5. lock (locker)
  6. {
  7. current_variable = variable;
  8. Monitor.PulseAll(locker);
  9. }
  10.  
  11.  
  12.  
  13. return current_variable;
  14.  
  15. }
  16.  
  17. public void Put(string i)
  18. {
  19. lock (locker)
  20. {
  21. while (variable.Count(x => x == 'A') < 3 && i != "A")
  22. {
  23.  
  24.  
  25. Monitor.Wait(locker);
  26.  
  27. if (isDone == true)
  28. {
  29. return;
  30. }
  31. }
  32. variable = variable + i;
  33.  
  34. Monitor.PulseAll(locker);
  35.  
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement