Created
January 2, 2018 19:59
-
-
Save eneko/fc035f7d2d9d433fabb408c7b1f37ef9 to your computer and use it in GitHub Desktop.
Swift 4 Dispatch on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Dispatch | |
let semaphore = DispatchSemaphore(value: 0) | |
DispatchQueue.global().async { | |
print("Hello, world!") | |
semaphore.signal() | |
} | |
semaphore.wait() | |
print("Bye!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ swift run | |
Hello, world! | |
Bye! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment