Class LockHelper


  • public class LockHelper
    extends Object
    Helper to make trying for read-write locks simpler
    Since:
    4.1.7
    Author:
    Derek Hulley
    • Constructor Detail

      • LockHelper

        public LockHelper()
    • Method Detail

      • tryLock

        public static void tryLock​(Lock lock,
                                   long timeoutMs,
                                   String useCase)
                            throws LockHelper.LockTryException
        Try to get a lock in the given number of milliseconds or get an exception
        Parameters:
        lock - the lock to try
        timeoutMs - the number of milliseconds to try
        useCase - String value which specifies description of use case when lock is needed
        Throws:
        LockHelper.LockTryException - the exception if the time is exceeded or the thread is interrupted