[concurrency-interest] On the specification of park()
dl at cs.oswego.edu
Sat Sep 24 12:51:53 EDT 2016
On 09/24/2016 11:47 AM, Andrew Haley wrote:
> The spec says
>> The park method may also return at any other time, for "no reason",
> Looking at the OpenJDK implementation, I don't think it will do that.
> What is the reason park() is specified this way?
There's a lot of mythology and controversy about this
(as the first bunch of google hits will point you to), but the
main reason is that when finite resources (hardware or memory) are
used to implement blocking for a series of conditions, there can
be races in which a signal for the previous usage cannot be
distinguished from a signal to the new usage, so a wakeup occurs
to be safe. This is usually the case for example when using
immortal typed memory pools, which is (or at least was) the case
for hotspot's thread.parker field.
More information about the Concurrency-interest