Module watamebot

Class SingleInstanceUtil

java.lang.Object
net.foxgenesis.util.SingleInstanceUtil

public final class SingleInstanceUtil extends Object
Utility class that tries to create a Lock on a specific PID file. If the locking fails, we know that another instance of the application is running.
Author:
Spaz-Master, Ashley
  • Constructor Details

    • SingleInstanceUtil

      public SingleInstanceUtil()
  • Method Details

    • waitAndGetLock

      public static void waitAndGetLock(int amt)
      Attempt to obtain lock on PID with amt retries.

      This method is equivalent to

       SingleInstanceUtil.waitAndGetLock(8007, amt, 10_000)
       
      Parameters:
      amt - - Amount of retries before failing to obtain lock
      Throws:
      SingleInstanceUtil.SingleInstanceLockException - Thrown if try count equals or exceeds amt
      See Also:
    • waitAndGetLock

      public static void waitAndGetLock(File file, int amt)
      Attempt to obtain lock on PID with amt retries and 10 second delay between retries.

      This method is equivalent to

       SingleInstanceUtil.waitAndGetLock(8007, amt, 10_000)
       
      Parameters:
      file - - location of PID file should attempt to lock
      amt - - Amount of retries before failing to obtain lock
      Throws:
      SingleInstanceUtil.SingleInstanceLockException - Thrown if try count equals or exceeds amt
      See Also:
    • waitAndGetLock

      public static void waitAndGetLock(File file, int amt, int delay)
      Attempt to obtain lock on PID file pid, amt times with delay delay between retries.
      Parameters:
      file - - location of PID file
      amt - - Amount of retries before failing to obtain lock
      delay - - Delay between retries
      Throws:
      SingleInstanceUtil.SingleInstanceLockException - Thrown if try count equals or exceeds amt
      See Also: