Sobes.tech
Middle — Senior

What is the output order? No. 37

livecode

Task condition

Determine the order in which the numbers will be printed when executing the following Swift code:

func printNumbers() {
    print(1)
    DispatchQueue.main.async {
        print(2)
        DispatchQueue.main.async {
            print(3)
            DispatchQueue.global().sync {
                print(4)
            }
        }
        print(5)
    }
    print(6)
}
print(7)