Why doesn't .async on a concurrent queue in a for loop behave the same as DispatchQueue.concurrentPerform?
问题 import Dispatch class SynchronizedArray<T> { private var array: [T] = [] private let accessQueue = DispatchQueue(label: "SynchronizedArrayAccess", attributes: .concurrent) var get: [T] { accessQueue.sync { array } } func append(newElement: T) { accessQueue.async(flags: .barrier) { self.array.append(newElement) } } } If I run the following code, 10,000 elements are appended to the array as expected even if I am reading concurrently: DispatchQueue.concurrentPerform(iterations: 10000) { i in _