new java.util.BitSet and Synchronization
Michael Warres
mpw at cs.brown.edu
Tue Oct 20 10:14:35 PDT 1998
Archie Cobbs writes:
> Parmelan, Edouard writes:
> > The problem is a possible dead lock, and I don't know how to workaround:
> >
> > Imagine two BitSet a and b, and two threads t1 and t2.
> > t1 executes a.equals(b)
> > t2 executes b.equals(a)
> >
> > equals() should lock a and b in the same order for the two threads
> > but I don't know how to check the order :(
Use System.identityHashCode() to get the unique hash codes for each BitSet, then
lock the BitSet with the lower identity hash value first. This guarantees a
fixed locking order.
-Mike
--
Mike Warres
Systems Programmer
Brown University Computer Science Department
mpw at cs.brown.edu
More information about the kaffe
mailing list