Avatar
norio_nomura 7/4/2018 10:51 AM
@swift-4.1.3 import Foundation let group1 = DispatchGroup() func a(_ name: String) { print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") } DispatchQueue.global().async(group: group1) { a("Anna") } DispatchQueue.global().async(group: group1) { a("Bob") } DispatchQueue.global().async(group: group1) { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") exit(0) } dispatchMain()