Please: try-with-resouces Lock support!

Gernot Neppert mcnepp02 at
Wed Feb 23 09:31:53 PST 2011

  Hi all,

this has been discussed here before, but somehow got lost:
Wouldn't it be very handy having a class 
"java.util.concurrent.AutoLockable" that could be used as follows:

try(AutoLockable locked = AutoLockable.locked(lock))
// Do something in locked scope

It would look something like this:

package java.util.concurrent.locks;

public abstract class AutoLockable implements AutoCloseable {

     public static AutoLockable locked(final Lock lock)
         return new AutoLockable() {

             public void close() {

     public abstract void close();

More information about the coin-dev mailing list