When you write a Java™ application that requires transactions, you must consider issues
such as lock handling, collision handling, and transaction isolation.
Using locking
Locks have life cycles and different types of locks are
compatible with others in various ways. Locks must be handled in the
correct order to avoid deadlock scenarios.