global().async + main.async: what order does it print?
Task
The code runs on the app's main thread.
func run() {
print("2")
DispatchQueue.global().async {
print("3")
DispatchQueue.main.async {
print("4")
}
print("5")
}
print("6")
}
print("1")
run()
print("7")
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep