InterviewSolution
Saved Bookmarks
| 1. |
Explain the meaning of the deadlock and when it can occur? |
|
Answer» Deadlock, as the name SUGGESTS, is a situation where MULTIPLE threads are BLOCKED FOREVER. It generally occurs when multiple threads HOLD locks on different resources and are waiting for other resources to complete their task. The above diagram shows a deadlock situation where two threads are blocked forever. Thread 1 is holding Object 1 but needs object 2 to complete processing whereas Thread 2 is holding Object 2 but needs object 1 first. In such conditions, both of them will hold lock forever and will never complete tasks. |
|