Last active
July 6, 2018 10:41
-
-
Save cooler333/894f06f0a26d3c3ff4c15201b495ed22 to your computer and use it in GitHub Desktop.
This file contains 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
import Foundation | |
class UIViewContoller { | |
func viewDidLoad() { | |
// 1st case | |
print("1") | |
DispatchQueue.main.async { | |
print("2") | |
DispatchQueue.main.sync { | |
print("3") | |
} | |
print("4") | |
} | |
print("5") | |
// end 1st case | |
// 2nd case | |
print("6") | |
let serialQueue = DispatchQueue(label: "CustomQueue", qos: .background) | |
serialQueue.async { | |
print("7") | |
serialQueue.sync { | |
print("8") | |
} | |
print("9") | |
} | |
print("10") | |
// end 2nd case | |
// 3rd case | |
print("11") | |
DispatchQueue.global().async { | |
print("12") | |
DispatchQueue.global().sync { | |
print("13") | |
} | |
print("14") | |
} | |
print("15") | |
// end 3rd case | |
} | |
} | |
// Abstract | |
let vc = UIViewContoller() | |
print("16") | |
vc.viewDidLoad() | |
print("17") | |
/* | |
Question: what will be printed in console? | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment