IF fromAccount is locked THEN
IF toAccount is locked THEN
withDraw money from the fromAccount
deposit money into the toAccount
END IF
END IF
You may also remember that this was multithreaded code originally written to create a deadlock. In order to demonstrate Explicit Locking’s Lock interface and ReentrantLock implementation I needed to add a thread locking mechanism to my straight-forward Account POJO and so, the question was: how should I do this?