[jmm-dev] VarHandle.safepoint() methods

David Holmes david.holmes at oracle.com
Thu Jan 5 20:57:37 UTC 2017


<trimming>

On 5/01/2017 11:49 PM, Andrew Haley wrote:
> On 05/01/17 13:03, David Holmes wrote:
>>> Sure.  I was thinking of a version of VarHandle.safepoint() which took a
>>> timeout: if a safepoint didn't arrive after N seconds, force one.
>>
>> I'd be interested to hear what mechanism you envisage for waiting for,
>> and detecting, that a safepoint has arrived.
>
> I'm a bit bewildered by this question.  When a thread is safepointed
> it gets told by the VM to safepoint.  All it has to do is wait for that
> to happen.  Why does that matter anyway?

Taking a thread to a safe-point is a side-effect of its execution, 
imposed on it by the VM. You now want to add an API that is something 
like waitForsafepoint() and my question is how would you implement that? 
As we previously mentioned you might do something simplistic like a 
polling sleep with some kind of check of a safepoint count, and as soon 
as we see an updated count we know a safepoint has occurred. But that is 
a bit crude/inefficient and I was wondering if you had considered a more 
explicit mechanism?

David

> Andrew.
>


More information about the jmm-dev mailing list