[concurrency-interest] jdk9 VarHandle and Fence methods

Doug Lea dl at cs.oswego.edu
Fri Sep 4 07:18:29 EDT 2015

On 09/03/2015 02:19 PM, Oleksandr Otenko wrote:
> Has anyone come up with the answer about ordering for tryLock, or have I missed it?

You missed the dog not barking :-)

The Lock specs don't require any specific HB effects here on failed
tryLock. Even if we wanted to, we cannot retroactively impose any
considering that anyone can implement the Lock interface (not just j.u.c)
and some of these might become in violation.

As you and Vitaly pointed out, there are a few fringe cases where
users might want to impose ordering on failure. In jdk9, you'll
me able to do this with moded VarHandle accesses and/or fences. The
resulting extra fencing might be redundant here and there, but if you
cared enough, you could create and rely on custom locks with stronger


More information about the Concurrency-interest mailing list