How To Avoid Deadlock In Java,
What to do if deadlock happens in Java?
Change indexes.nnAfter you enable the 1204 and 1222 trace flags and determine which indexes are getting deadlocked, you can often eliminate deadlocks by adding an index, changing an index, or every once in a while by deleting an index.23-Mar-2019
How can we avoid deadlock in code?
A solution for a problem is found at its roots. In deadlock it is the pattern of accessing the resources A and B, is the main issue. To solve the issue we will have to simply re-order the statements where the code is accessing shared resources.
How can deadlock be prevented?
The common solution to preventing deadlock in code is to make sure the sequence of locking occur in a common manner regardless of which thread is accessing the resources. For example given threads T1 and T2, where T1 accesses resource A and then B and T2 accesses resource B and then A.16-May-2011