Class Locker

  • All Implemented Interfaces:
    AutoCloseable

    public class Locker
    extends Object
    implements AutoCloseable

    Utility for safely acquiring a lock and releasing it using Java 7's try-with-resource feature.

    Canonical usage:

         InterProcessMutex mutex = new InterProcessMutex(...) // or any InterProcessLock
         try ( Locker locker = new Locker(mutex, maxTimeout, unit) )
         {
             // do work
         }