Package sac.utils

Class Lock

java.lang.Object
sac.utils.Lock

public class Lock extends Object
A static lock for a specific delay

A Locker has three states:

  • not started
  • started and locked (non-expired)
  • started and unlocked (expired)
  • Constructor Details

    • Lock

      public Lock()
      Initializes a new Lock
  • Method Details

    • lock

      public void lock(int delayMills)
      Lock for a specific delay.

      The lock will automatically expire after delayMills.

      Parameters:
      delayMills - The time to lock the Lock.
    • isStarted

      public boolean isStarted()
      Check whether there is a lock.
      Returns:
      Whether the user has called lock()
    • isLocked

      public boolean isLocked()
      Check whether there is a non-expired lock.
      Returns:
      Whether there is a valid lock, and the lock isn't expired.
    • unlock

      public void unlock()
      Remove the lock.