I'm new to Swift. I saw some NSLock examples online and they are all like below:
let lock = NSLock()
func test() {
// some code
}
func run() {
lock.lock()
test()
lock.unlock()
}
If the test function crashes, the lock will never be unlocked, so next call to the run function will be in dead lock. Is it true? if so, how to fix it?