>>>>> "Georg" == Georg Rehfeld <[EMAIL PROTECTED]> writes:
Georg> notifyAll seems to be MUCH better as of the docs:
Georg> | The awakened threads will compete in the usual manner with |
Georg> any other threads that might be actively competing to |
Georg> synchronize on this object; for example, the awakened threads
Georg> | enjoy no reliable privilege or disadvantage in being the
Georg> next | thread to lock this object.
Georg> So every thread, if it was waiting before or just coming in
Georg> fresh, has the same chance to get the lock and proceed,
Georg> avoiding starvation.
this is not implied by the snippet you posted. all it says is that
the threads in the wait set "will compete in the usual manner", which
is no more fully specified than the case with notify(). no scheduling
method is implied in either notify() or notifyAll(), so you can make
no guarantees of fairness. also, notifyAll() can lead to the
so-called 'thundreing herd' of threads waking, competing for the lock,
and (all but one) going back to sleep again.
that said, any quality JVM will implement some sort of quasi-fair
scheduling policy, so it's not likely to lead to starvation. but if
you really want fairness, you cannot rely on the builtins.
there is a excellent discussion of this, and some examples on writing
a FIFO scheduler, in Doug Lea's 'Concurrent Programming in Java, 2nd
Ed', which I recommend highly.
--
joe
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development