Sobes.tech
Junior — Senior

Determine what output program №34 will produce

livecode

Task condition

This Swift example creates a concurrent queue and places two tasks into it: the first runs asynchronously, and the second synchronously. You need to predict which lines will be printed and in what order.

import Foundation

let workQueue = DispatchQueue(label: "com.example.concurrent", attributes: .concurrent)

workQueue.async {
    for index in 0..<100 {
        print("Task 1 - \(index)")
    }
}

workQueue.sync {
    for index in 0..<100 {
        print("Task 2 - \(index)")
    }
}