Daily iOS
ConcurrencyKuaishou

Serial vs concurrent sync

You call this function, which takes a GCD queue, from the main thread. About how many seconds until it returns? Answer for (1) a serial queue and (2) a concurrent queue.

func run(on queue: DispatchQueue) {
    queue.async { Thread.sleep(forTimeInterval: 5) }
    queue.sync  { Thread.sleep(forTimeInterval: 3) }
}

Pick one

Submit