Skip to content

Instantly share code, notes, and snippets.

@eneko
Created January 2, 2018 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eneko/fc035f7d2d9d433fabb408c7b1f37ef9 to your computer and use it in GitHub Desktop.
Save eneko/fc035f7d2d9d433fabb408c7b1f37ef9 to your computer and use it in GitHub Desktop.
Swift 4 Dispatch on Linux
import Dispatch
let semaphore = DispatchSemaphore(value: 0)
DispatchQueue.global().async {
print("Hello, world!")
semaphore.signal()
}
semaphore.wait()
print("Bye!")
$ swift run
Hello, world!
Bye!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment