Last active
June 12, 2018 22:36
-
-
Save deda9/32a191ca05a248ee0ffa95eecc5f2bbd to your computer and use it in GitHub Desktop.
How to create DispatchGroup
This file contains hidden or 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 group = DispatchGroup() | |
group.enter() | |
let dispatchQueue1 = DispatchQueue.init(label: "dispatchQueue") | |
dispatchQueue1.sync { | |
for i in 0..<5 { | |
print("DispatchQueue X ", i) | |
} | |
group.leave() | |
} | |
group.enter() | |
dispatchQueue1.sync { | |
for i in 0..<5 { | |
print("DispatchQueue Y ", i) | |
} | |
group.leave() | |
} | |
group.notify(queue: dispatchQueue1){ | |
print("Dispatch group finished the work") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment