Is this safe to call wait() of DispatchSemaphore several times at one time?
I got three dispatched threads named queueA, queueB, queueC. Now I want the queueA executed after queueB and queueC done. So I tried to implement it by DispatchSemaphore . My Problem is: Is this safe to call wait() two times in a thread at one time to make the semaphore 2? self.semaphore.wait() // +1 self.semaphore.wait() // +1 The following is the entire test code: class GCDLockTest { let semaphore = DispatchSemaphore(value: 0) func test() { let queueA = DispatchQueue(label: "Q1") let queueB = DispatchQueue(label: "Q2") let queueC = DispatchQueue(label: "Q3") queueA.async { self.semaphore