Created
January 22, 2017 13:20
-
-
Save mikru1688/63330070e1ee7acc5f5ab2a23516c9dd to your computer and use it in GitHub Desktop.
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
// 非同步佇列的使用方式與驗證非同步執行的結果 | |
let concurrentQueue1: DispatchQueue = DispatchQueue(label: "concurrentQueue1", attributes: .concurrent) | |
let concurrentQueue2: DispatchQueue = DispatchQueue(label: "concurrentQueue2", attributes: .concurrent) | |
let concurrentQueue3: DispatchQueue = DispatchQueue(label: "concurrentQueue3", attributes: .concurrent) | |
concurrentQueue1.async { | |
for i in 1 ... 10 { | |
print("i: \(i)") | |
} | |
} | |
concurrentQueue2.async { | |
for j in 100 ... 109 { | |
print("j: \(j)") | |
} | |
} | |
concurrentQueue3.async { | |
for k in 200 ... 209 { | |
print("k: \(k)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment