In iOS development, nslock is commonly used to achieve simple mutual exclusion. Nslock operations include lock, unlock, trylock, and lockbeforedate. Therefore, the so-called lock and unlock are simple thread locks. trylock and lockbeforedate are two methods implemented by IOS without blocking threads.
Trylock does not block the thread. If the lock fails, no is returned;
Lockbeforedate is used to determine when to unlock the data.
The nsrecurisvelock, nscoditionlock, and nsdistributelock are recursive locks in IOS.
Recursive lock nsrecurisvelock: it is usually used in recursion and does not cause thread blocking. However, the lock and unlock must be paired.
Conditional lock nscoditionlock: You can pass in a public variable as a condition to synchronize data at different thread times.
Distribution lock nsdistributelock: Used as the lock condition for files, which can be accessed between different processes to achieve process synchronization.
In addition, @ synchronize can be used in IOS to achieve thread mutex. The objc object can be used as a token between different threads.
Parsing locks in objective-C