I'm curious, this is not something I've needed to know, but what would be Java specific to an answer?
If I was asked about deadlocks, I would say "always acquire resources in the same order".
I don't think that's the correct solution, unfortunately - see e.g. the dining philosophers problem.
Edit: or rather, you have to be very careful what the "order" of resources is.
I imagine it would take half a day or reading to remember it again.
I'm curious, this is not something I've needed to know, but what would be Java specific to an answer?
If I was asked about deadlocks, I would say "always acquire resources in the same order".