[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: It's been quiet for a while...
I sent this reply to Rick only i.s.o. to the whole group, so here is my
reaction again for the others...
>...so here is an item for discussion.
>
>The attached is JServLock.java (from JServ v0.9.11), a lockable resource
>for synchronising threads within the Java/Apache webserver (see
>http://java.apache.org)
>
>I'm not familiar with the quoted reference to Doug Lea's work, although
>I have heard of it before. Can I invite comment about the similarities
>and differences between this locking class and the JCSP channel classes
>(http://www.cs.ukc.ac.uk/projects/ofa/jcsp/)?
Ok, here goes:
The big difference between this code and the code Peter Welch showed in
his talk on Java and CSP, which I think is also in the JCSP is the following:
In the code that you sent us there is a piece of code such as:
if (!condition)
{
wait();
}
and in some other part there is a notifyAll();
Peter, in his talk explained that because of the NotifyAll() the fact that
you get out of the wait() does not mean that the condition is now satisfied.
The code should be
while (!condition)
{
wait();
}
to make sure that the condition is indeed satisfied after the wait();
This is the difference that I see that makes me wonder whether this
locking really works in practice.
I am writing this from the top of my head at 0:00 so don't be too harsh
on me if I didn't remember right... ;-)
>Regards,
>Rick
Regards,
Herman