new java.util.BitSet and Synchronization

Archie Cobbs archie at whistle.com
Tue Oct 20 09:58:47 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 :(
> 
> You could have a single static Object variable and synchronize
> on it before doing any operations that involve multiple BitSet
> objects...

Forgot to mention that you would also have to *then* lock the
BitSet objects involved as well, after obtaining the static 
variable lock.

-Archie

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


More information about the kaffe mailing list