[kepler-dev] Threading issue with waits and notifies

Colin Enticott Colin.Enticott at csse.monash.edu.au
Wed Oct 21 06:47:52 PDT 2009


This question is probably directed at Edward again.

Another thread lock issue. I noticed the workspace class has a wait
method that releases all the workspace read locks and acquires a lock
on the given object and waits. Very handy. Looking at the method in
Kepler 1.0.0 (apologies if it has been updated), it obtains a lock on
the given object after it releases the read locks on the workspace (It
has to do this to avoid deadlocks). From this, I can't see a way of
synchronising a call to the object's notify method from another thread
as the notify could happen before the first thread goes into wait().
Looking at the code for the ProcessDirector, it assumes that the
director's thread is waiting. If you have multiple threads waking the
director, I guess the odds are very low of a permanent deadlock. Has
this manifested as an issue before?

As a work around, I do my own releaseReadPermission()
reaquireReadPermission() combination, but with an "if" statement to
check if the thread should wait() inside the object lock. I guess an
ideal solution would be to create a notify(Object) and
notifyAll(Object) methods in the workspace class that are safe.
Thoughts?

Regards,
Colin


More information about the Kepler-dev mailing list