[concurrency-interest] Why can't wait-set Threads be privileged?

thurstonn thurston at nomagicsoftware.com
Sat Jun 29 22:27:49 EDT 2013


So, in java the behavior of Object.wait and Object.notify():

Thread 1:

obj.wait() // Thread 1 is put in the wait-set

Thread 2: 

obj.notify() // Select a Thread from the wait-set and move it to the
*entry-set*



What I've always wondered is why there isn't some sort of 'overloaded'
Object.notify(...) that would essentially do:
whichever thread is selected from the notify() call, put it at the 'head' of
the wait-set so that it will enter the monitor next. (Note: what I'm
suggesting is not the same thing as the 'fairness' parameter to
ReentrantLock, e.g.)

Obviously wait() and notify() are native methods, so what I'm wondering is:
is this a limitation in modern OS's? CPUs?

I don't know enough about the actual implementation to know what the issues
are, but this would definitely be a useful feature (think multi-producer,
single-consumer, etc).

Of course there are other patterns that you can take to achieve similar
results, but it would appear to be a lot simpler if you could just specify
that is the behavior you want in an Object.notify(boolean: privilegewaiters)
or some equivalent.

Any insights?






--
View this message in context: http://jsr166-concurrency.10961.n7.nabble.com/Why-can-t-wait-set-Threads-be-privileged-tp9808.html
Sent from the JSR166 Concurrency mailing list archive at Nabble.com.


More information about the Concurrency-interest mailing list