Skip to content

Instantly share code, notes, and snippets.

@drewmccormack
Created February 2, 2019 16:39
Show Gist options
  • Save drewmccormack/4c8f0516cd6f70b2ee5a0dcce9bb1ee8 to your computer and use it in GitHub Desktop.
Save drewmccormack/4c8f0516cd6f70b2ee5a0dcce9bb1ee8 to your computer and use it in GitHub Desktop.
Simple example of multi-threading with mutable struct.
import Foundation
struct Small {
var i: Int
var j: Int
}
var s = Small(i: 1, j: 2)
DispatchQueue.global(qos: .background).async {
let s2 = s
print("\(s2)")
}
s = Small(i: 3, j: 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment