by saagarjha · 8y ago · 0 comments
import Foundation
let q1 = DispatchQueue(label: "1")
let q2 = DispatchQueue(label: "2")
var a = [0]
q1.async {
a[0] = 1
}
q2.async {
a[0] = 2
}
You'll get an error at runtime that there's a data race.I believe this is pretty good evidence for my claim that understanding the thread safety is confusing.