Skip to content

Instantly share code, notes, and snippets.

@wotjd
Created August 5, 2019 08:47
Show Gist options
  • Save wotjd/c9a8ab7c014127485ec2557191d0c1bf to your computer and use it in GitHub Desktop.
Save wotjd/c9a8ab7c014127485ec2557191d0c1bf to your computer and use it in GitHub Desktop.
import Foundation
DispatchQueue.global().sync {
print("hi")
}
print("good")
let serial = DispatchQueue(label: "Serial")
let concurrent = DispatchQueue(label: "Concurrent", attributes: .concurrent)
concurrent.async {
print("concurrent async in")
// it works!
concurrent.sync {
print("concurrent sync of concurrent async")
}
print("concurrent async out")
}
serial.async {
print("serial async in")
// X_X
serial.sync {
print("serial sync of serial async")
}
print("serial async out")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment