sync
するように書き直したら一瞬で終わりましたw public class SynchronizedDictionary<Key: Hashable, Value> { private var dictionary: [Key: Value] = [:] private let queue = DispatchQueue(label: "shit", qos: .default) public subscript(_ key: Key) -> Value? { get { queue.sync { dictionary[key] } } set { queue.sync { self.dictionary[key] = newValue } } } } var a = SynchronizedDictionary<Int, Int>() let n = 100000 DispatchQueue.concurrentPerform(iterations: n) { i in a[i] = i }
(edited)