main.cs1184 chars57 lines
In this code, two threads are created to read a file. The ReadFile1
function acquires lock1
first and then lock2
, while the ReadFile2
function does the opposite. This creates a circular dependency that results in a deadlock. Each thread is waiting for the other to release the lock it needs. This deadlock will cause the program to freeze and hang indefinitely.
gistlibby LogSnag