When does a deadlock occur?
Anoniem
When the locks are accessed in wrong order. Basically one thread picks lock A first and lock B after, while at the same time another thread picks lock B first and lock A after. This can be solved by comparing the participating objects system hashcodes and re-ordering the locks accordingly.