Avatar
@swiftbot import Foundation //import PlaygroundSupport //PlaygroundPage.current.needsIndefiniteExecution = true let group1 = DispatchGroup() func a(_ name: String) { group1.enter() print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } DispatchQueue.global().async { a("Anna") } DispatchQueue.global().async { a("Bob") } DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") //PlaygroundPage.current.finishExecution() } // Xcode 9.4.1 と 10.0 beta2 どちらも同じ結果でした /* Playground Settings - Platform: macOS Good night, Cony.. Good night, Anna.. Good night, Bob.. Morning, Cony! Morning, Bob! Morning, Anna! *** Good morning, all! *** */ /* Playground Settings - Platform: iOS Good night, Anna.. Good night, Cony.. Good night, Bob.. *** Good morning, all! *** */
🛠 1