@frozen public struct Array<Element> {
This is the declaration of Array in swift. struct in swift is thread-safety, Array is struct, why Array is not thread-safety?
First, I declare a struct.
struct MyStruct {
var testArray: [Int] = [1]
}
Then, I write a concurrent test, It crashed when running
var test = MyStruct ()
DispatchQueue.concurrentPerform(iterations: 500) { index in
test.testArray.append (100) //Thread 14: EXC_BAD_ACCESS (code=1, a...
}