Interaction with Java monitors

Java monitors can deadlock with transaction locks. Figure 4.1, “Undetected deadlock” shows an undetected deadlock between a Java monitor and a transaction lock.

Undetected deadlock

Figure 4.1. Undetected deadlock


To avoid undetected deadlocks between monitors and transaction locks, monitors should not be used with transactional resources. In general, monitors are not needed in a transactional system because transaction isolation provides the same data integrity guarantees with much better concurrency and ease of use.