Deadlock is a situation when two or more threads are waiting on each other to be completed causing both to be locked and not able to continue.
A practical example of a deadlock is
Let’s see an example in swift.
here, the the queue is exeucting with q.async first, inside the block it calls for q.sync. So the outer block can only complete when the inner block q.sync is finished, but q.sync cannot start, because it is a sync block unless the thread is free. This results in a deadlock and the process will crash.