Class LockUtil

java.lang.Object
io.camunda.zeebe.util.LockUtil

public final class LockUtil extends Object
Utility class for common tasks with Lock instances.
  • Method Details

    • withLock

      public static void withLock(Lock lock, Runnable runnable)
      Runs the given operation only when the lock has been obtained. Locks interruptibly, meaning if the thread is interrupted while waiting for the lock, the runnable is not executed.
      Parameters:
      lock - the lock to acquire
      runnable - the operation to run
    • withLock

      public static void withLock(Lock lock, Runnable runnable, org.agrona.ErrorHandler errorHandler)
      Runs the given operation only when the lock has been obtained. Locks interruptibly, meaning if the thread is interrupted while waiting for the lock, the runnable is not executed. If interrupted, calls the error handler.
      Parameters:
      lock - the lock to acquire
      runnable - the operation to run
      errorHandler - called if an error occurs during interruption