Skip to content

Instantly share code, notes, and snippets.

@sebcode
Created September 16, 2016 21:25
Show Gist options
  • Save sebcode/39ea52e994ec6f114d47c99f118c0afa to your computer and use it in GitHub Desktop.
Save sebcode/39ea52e994ec6f114d47c99f118c0afa to your computer and use it in GitHub Desktop.
import Cocoa
let queue = Cocoa.OperationQueue()
let sema = DispatchSemaphore.init(value: 0)
queue.addOperation {
print("T1 Wait")
queue.addOperation {
sleep(5)
print("T2 Signal")
sema.signal()
}
_ = sema.wait(timeout: .distantFuture)
print("T1 DONE")
exit(0)
}
print("Runloop")
CFRunLoopRun()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment