More on Deadlock in 5.6

Of course, the best way to deal with a deadlock occurring in your Java program is to change your FSP to model the situation of multiple threads accessing the account and ensure that LTSA declares your model deadlock free. Then translate the model into Java and your Java program should be deadlock free.

Hint: if you're Java program is deadlocking on the conditions mentioned in my previous What's New post then you are not handling mutual exclusion on the account correctly. In particular, you don't a thread making its choice about whether to do a withdrawal or deposit before it knows what the balance is. What needs to be atomic in the system is learning the balance and then making a choice about whether you want to do a deposit or a withdrawal.

Kenneth M. Anderson, 2009