What does this GCD code print? (main.sync and the run loop)
Task
func printMultithreading() {
print("2")
DispatchQueue.global().async {
print("3")
DispatchQueue.main.sync { print("4") }
print("5")
}
print("6")
}
print("1")
printMultithreading()
print("7")
RunLoop.main.run(until: Date(timeIntervalSinceNow: 5))
What prints, in which order, and what changes without the last line?
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep