https://github.com/goto-eof/jlock
A mini jar to ensure the uniqueness of execution of an java application
https://github.com/goto-eof/jlock
Last synced: 3 months ago
JSON representation
A mini jar to ensure the uniqueness of execution of an java application
- Host: GitHub
- URL: https://github.com/goto-eof/jlock
- Owner: goto-eof
- Created: 2022-09-03T17:45:53.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-07T17:22:03.000Z (over 2 years ago)
- Last Synced: 2024-12-30T03:44:30.434Z (5 months ago)
- Language: Java
- Homepage:
- Size: 416 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JLock
A jar to ensure the uniqueness of execution of an java application.
### How to use it?
At the application startup
```java
JLock jLock = new JLock("MY_APPLICATION_NAME", ENABLE_AUTOMATIC_UNLOCK);
if (jLock.isLocked()){
MessageDialog.error(your_jform, "Application is already running!");
System.exit(3);
}
```where `MY_APPLICATION_NAME` is the application name and the boolean `ENABLE_AUTOMATIC_UNLOCK`, if true, enables the automatic unlocking when `System.exit(X)` is called.
To release automatically (ENABLE_AUTOMATIC_UNLOCK have to be true):
```java
System.exit(status);
```To release manually:
```java
jLock.release();
```## Maven
```xml
it.dodu
jlock
1.0.0```