Unsafe: removing the monitorEnter/monitorExit/tryMonitorEnter methods

Brian Goetz brian.goetz at oracle.com
Fri Feb 28 22:17:38 UTC 2014

Except that Lock has features that are not supported by intrinsic locks 
(timed wait, interruptible wait.)  So the Lock returned would not 
conform to Lock's contract, and attempting to call these methods would 
probably throw UOE.

On 2/27/2014 6:12 AM, Stephen Colebourne wrote:
> On 26 February 2014 20:54, Martin Buchholz <martinrb at google.com> wrote:
>> It does seem that being able to tell whether a java object monitor is
>> currently locked is useful for debugging and monitoring - there should be a
>> way to do that.
> Perhaps it would be useful to be able to expose a java object monitor
> as an instance of Lock?
> Lock lk = Lock.ofMonitor(object)
> if (lk.tryLock()) {
>    ...
> }
> Such a method feels like it would be a useful missing link between
> synchronized and locks.
> Stephen

More information about the core-libs-dev mailing list