Last active
March 6, 2017 20:23
-
-
Save creaaa/a894b91c402b0d02a3331e0303ef6d17 to your computer and use it in GitHub Desktop.
Ishikawa Book: GCD
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 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