Last active
November 30, 2018 04:30
-
-
Save piyush23dez/f71779899472443bdaa0d4dd9d2d70c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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