Skip to content

Instantly share code, notes, and snippets.

@almaleh
Last active January 14, 2020 01:21
Show Gist options
  • Save almaleh/50b1a58c04a93ee7ba9c8f01dca039cb to your computer and use it in GitHub Desktop.
Save almaleh/50b1a58c04a93ee7ba9c8f01dca039cb to your computer and use it in GitHub Desktop.
let serial1 = DispatchQueue(label: "com.besher.serial1")
let serial2 = DispatchQueue(label: "com.besher.serial2")
serial1.sync { // <---- we changed this to 'sync'
for _ in 0..<5 { print("🔵") }
}
// we don't get here until first loop terminates
serial2.async {
for _ in 0..<5 { print("🔴") }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment