Skip to content

Instantly share code, notes, and snippets.

@mikru1688
Created January 22, 2017 13:20
Show Gist options
  • Save mikru1688/63330070e1ee7acc5f5ab2a23516c9dd to your computer and use it in GitHub Desktop.
Save mikru1688/63330070e1ee7acc5f5ab2a23516c9dd to your computer and use it in GitHub Desktop.
// 非同步佇列的使用方式與驗證非同步執行的結果
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