Avoiding Deadlock using Multithreading in Java
By Tanya Saxena
A simple and easy to understand deadlock occurence and deadlock fixing example of multithreading in java.
Multithreading in Java
Software Used - IntelliJ Idea
There are two multithreading concepts programmed here namely deadlock occurence and deadlock fixing.
Firstly a deadlock situation is created. This happens when multiple processes request for the same process to start their execution. The resources in this stage gets locked with a particular process till that process completes its execution. This leads to a situation where no process can complete its execution.
Then deadlock fixing is performed, the deadlock is fixed by preventing resources required by other process getting locked with the first process. This is done by allowing other process request for the resources and will be assigned the resources only when the initial process completes its execution.