IOS Study Notes-deadlock comprehension, iosdeadlock
1. First, let's take a look at the explanation in the official documentation. The queue of this block is executed synchronously. Unlike asynchronous, this method will not return until the block is executed.
2. Once the main thread is enabled, you must execute your code before executing the task added to the main queue.
Cause of deadlock:
A) The dispatch_sync method will not be returned until the block is executed.
B) once the main thread is enabled, you must execute your own code before executing the task added to the main queue.
C) if the main thread wants to execute the block, it must first execute the following code. However, because of the dispatch_sync method, if the result cannot be returned, the main thread cannot be executed again, causing a deadlock, so the main thread is stuck here, causing a deadlock.