MicroStrategy Interview Question

What is deadlock, how to prevent it

Interview Answer

Anonymous

Oct 4, 2018

A deadlock occurs when two or more threads holding the process and did not release the signal when it finishes it. The other thread is always waiting for the signal and doing nothing, which will cause a deadlock. When you doing multithreading, you can add a lock to the variable which will be used in the multithread. When one thread was manipulating the data, the lock would lock it and no other threads can touch that variable. After the working thread finished work, it would release the signal telling other thread that it finished the work, and other threads can manipulate the data.