SHARE
TWEET

Untitled

a guest Sep 23rd, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var semaphore = DispatchSemaphore(value: 1)
  2.  
  3. DispatchQueue.global().async {
  4.     print("T1 Start")
  5.     semaphore.wait()
  6.     print("T1 Enter")
  7.     sleep(2)
  8.     print("T1 Something complete")
  9.     semaphore.signal()
  10. }
  11. DispatchQueue.global().async {
  12.     sleep(1)
  13.     print("T2 Start")
  14.     semaphore.wait()
  15.     print("T2 Enter")
  16.     print("T2 Something complete")
  17.     semaphore.signal()
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top