InterviewSolution
| 1. |
How will you ensure that deadlock does not occur frequently? |
|
Answer» There are PLENTY of ways to prevent deadlock but the most reliable method is where we assign a particular order to the locks and then the same locks will be acquired by a different order. For example, consider that if CERTAIN threads need to acquire the locks of 1, 7 and 2 it is essential for it to acquire lock 1, which is then followed by lock 2 and lastly by lock 7. Following through this way we can easily prevent the thread trying to acquire the lock 1 followed by the lock 2 and different theatre trying to acquire the lock 2 and then lock 1. All of these together can contribute to deadlock. Though this is not the most frequent practice but still it is considered by many users. |
|