Sobes.tech
Back to tasks
Junior — Senior
43

Определите порядок вывода в консоль №15

Companies where asked:

EnjoyPro
Get help with live coding in real time with Sobes Copilot
Task condition
import UIKit

func performPrint() {
    print("1")

    DispatchQueue.main.sync {
        print("2")
    }

    DispatchQueue.main.async {
        print("3")
    }

    print("4")
    print("5")
}

let customQueue = DispatchQueue(label: "Queue", qos: .userInteractive, attributes: [], autoreleaseFrequency: .never, target: nil)

customQueue.async {
    performPrint()
}

Задача: проанализировать, в каком порядке появятся строки в консоли при выполнении данного кода.