let q = DispatchQueue.init(label:"test",qos:.background)
q.sync{
NSLog("q")
q.sync {
NSLog("\(Thread.current.isMainThread) \(Thread.current.name) \(Thread.current.qualityOfService)")
}
}
Why q.sync inside q.sync not printing out ?
>Solution :
This is called deadlock. The inner call q.sync waits for the first q.sync task to complete. The first q.sync task can’t complete because it has an inner q.sync waiting to be dispatched.
That’s the reason why you don’t call DispatchQueue.main.sync {...}
So the inner queue call has to be async in order not to cause deadlocks on serial queues.