title: Is struct thread safe in swift
body: <pre class="lang-swift prettyprint-override"><code>let queue1 = DispatchQueue(label: "queue1")
  let queue2 = DispatchQueue(label: "queue2")
  
  var list: [Int] = []
  public func changeList() {
      queue1.async {
          while true {
              if self.list.count &lt; 10 {
                  self.list.append(self.list.count)
              } else {
                  self.list.removeAll()
              }
          }
      }
  
      queue2.async {
          while true {
              // case 1
              // self.list.forEach { debugPrint($0) }
  
              // case 2
              let value = self.list
              value.forEach { debugPrint($0) }
  
              // case 3
              // var value = self.list
              //value.append(100)
          }
      } 
  }
  </code></pre>
  
  <p>I create two queue to handle an array in different thread. In one thread I write the array and in another thread I read the array. But why does it crash in case 1、case 2 and case 3. Does it mean struct is not thread safe.
  I have made <code>let value = self.list</code> in case 2.But it also crash, why???</p>