java.lang.Object
net.foxgenesis.util.SingleInstanceUtil
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException class thrown when SingleInstanceUtil fails to obtain a lock on its desired port. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidwaitAndGetLock(int amt) Attempt to obtain lock on PID withamtretries.static voidwaitAndGetLock(File file, int amt) Attempt to obtain lock onPIDwithamtretries and 10 second delay between retries.static voidwaitAndGetLock(File file, int amt, int delay) Attempt to obtain lock on PID filepid,amttimes withdelaydelay between retries.
-
Constructor Details
-
SingleInstanceUtil
public SingleInstanceUtil()
-
-
Method Details
-
waitAndGetLock
public static void waitAndGetLock(int amt) Attempt to obtain lock on PID withamtretries.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 exceedsamt- See Also:
-
waitAndGetLock
Attempt to obtain lock onPIDwithamtretries 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 lockamt- - Amount of retries before failing to obtain lock- Throws:
SingleInstanceUtil.SingleInstanceLockException- Thrown if try count equals or exceedsamt- See Also:
-
waitAndGetLock
Attempt to obtain lock on PID filepid,amttimes withdelaydelay between retries.- Parameters:
file- - location of PID fileamt- - Amount of retries before failing to obtain lockdelay- - Delay between retries- Throws:
SingleInstanceUtil.SingleInstanceLockException- Thrown if try count equals or exceedsamt- See Also:
-