Sobes.tech
Junior — Senior

What will be the output of program №33

livecode

Task condition

In this example, the program outputs messages before and after the synchronous execution of a task placed on the main thread. Note that calling DispatchQueue.main.sync from the main thread leads to a deadlock.

import Foundation

print("Start task")

DispatchQueue.main.sync {
    print("Executing task")
}

print("Finish task")