In the previous article, we talked about how deadlocks occur in Java while working in a multi-threaded environment. Now, we will see how to prevent deadlocks by explaining a couple of corner cases. Avoid Nested Locks In the previous article, we showed an example for deadlock, and it contains nested locks as follows. ... Thread … Continue reading How to Avoid Deadlocks in Java
Tag: deadlock
Understanding Java Thread DeadLock
In a multi-threaded environment, it is ok that multiple threads simultaneously handles their tasks to improve the CPU utilization instead of keeping CPU as idle. In such an environment, it is ok if multiple threads try to access a shared resource, only one of them can acquire lock and the others should wait for that … Continue reading Understanding Java Thread DeadLock