Guest User

Untitled

a guest
Sep 23rd, 2019
106
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