multithreading - Object intrinsic monitor as java.util.concurrent.Lock -
i believe useful able use object's monitor lock. :
synchronized(object) { ... } would equivalent :
lock.lock(); try { ... } { lock.unlock(); } as far understand it, not possible achieve using lock interface since synchronization happens in blocks. solution see have java.lang.object enriched method
public lock aslock/getintrinsicmonitorobject(); // name isn't perfect i'm not asking or :
locksupport.getintrinsicmonitorobject(object of); questions :
is there reasons isn't possible (i consider fact
trylockisn't possible synchronization isn't one)is there solution using existing jre classes ?
would jsr on make sense ?
the unsafe class* has support directly manipulate monitors:
public native void monitorenter(object o); public native void monitorexit(object o); public native boolean trymonitorenter(object o); *that's in java 8 think there in java 7
Comments
Post a Comment