Skip to content

Instantly share code, notes, and snippets.

@creaaa
Last active March 6, 2017 20:23
Show Gist options
  • Save creaaa/a894b91c402b0d02a3331e0303ef6d17 to your computer and use it in GitHub Desktop.
Save creaaa/a894b91c402b0d02a3331e0303ef6d17 to your computer and use it in GitHub Desktop.
Ishikawa Book: GCD
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let queue = DispatchQueue.global(qos: .userInitiated)
queue.async {
let isMainThread = Thread.isMainThread // false
print("非同期の処理")
let queue = DispatchQueue.main
queue.async {
let isMainThread = Thread.isMainThread // true
print(Array(0...10_000_000).reduce(0, +))
}
print("ありゃ!先にきちゃった!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment