"Kasparian, Raffi J." wrote:
>
> I have gotten no response after submitting this message twice to this
> message group and once to the Java3D beta program. Surely someone out there
> can at least tell me if it looks like I'm using synchronization properly in
> theory?
[...]
> synchronized( v ){// v is a Vector and a variable member of this class.
>         for( Enumeration e2 = v.elements(); e2.hasMoreElements(); ){
>                 OrderableBehavior r = (OrderableBehavior)e2.nextElement();
>                         r.run();
>         }
>         v.clear();
> }

Don't know what happens exactly, but most probably something in run
method is causing something else to try to get same lock from other
thread. Or something like this. Anyway, try to call run methods from
outside the lock. Something like

Vector oldVec;
synchronized (v)
{
   oldVec = v;
   v = new Vector();
}

for( Enumeration e2 = oldVec.elements(); e2.hasMoreElements(); )
{
   OrderableBehavior r = (OrderableBehavior)e2.nextElement();
   r.run();
}

or create a clone or perform toArray inside synchronized.

It is generally a good idea to keep synchronized blocks as short as
possible (sometimes even at cost of extra alloc as in this case).

Anyway, it would be nice to determine extactly what is causing a
deadlock - just for fun. Try locking jvm and then press CTRL-Break or
CTRL-/ (depending on platform) - you will get full thread dump. You
should be able to determine which thread (together with call trace) is
waiting on monitor held by other thread.

Artur

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to