new java.util.BitSet and Synchronization

Archie Cobbs archie at whistle.com
Tue Oct 20 09:55:13 PDT 1998


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 :(

You could have a single static Object variable and synchronize
on it before doing any operations that involve multiple BitSet
objects...

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com


More information about the kaffe mailing list