Skip to content

Instantly share code, notes, and snippets.

@piyush23dez
Last active November 30, 2018 04:30
Show Gist options
  • Save piyush23dez/f71779899472443bdaa0d4dd9d2d70c7 to your computer and use it in GitHub Desktop.
Save piyush23dez/f71779899472443bdaa0d4dd9d2d70c7 to your computer and use it in GitHub Desktop.
func threadSafeOperation() {
let foo = Foo()
let queue = DispatchQueue.global(qos: .default)
let locker = NSLock()
for _ in 0..<4 {
queue.async {
locker.lock()
foo.doIt()
locker.unlock()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment