Thursday, December 9, 2010

How to find the locking order for equals() ?

Always lock them in the same order, one way you could decide the order is on the results of System.identityHashCode(Object)

References:
http://stackoverflow.com/questions/1636399/correctly-synchronizing-equals-in-java
http://download.oracle.com/javase/tutorial/essential/concurrency/atomic.html


No comments: