How to create a real singleton for a whole computer in Java?
I have a console app written in Java. if application is executed for a second time I want it to know that the main application is already running (and executing jobs). The second execution will just allow the user to query data (jobs). I know I can create a file and write everything to it, but then I will have to also support computer resets, etc.
Is there a better way to do it?
to summarize:
- I start the app. It has jobs and execute them at wanten interval.
- I start app for a second time. I get message that jobs are already running and I can query data from the first app.
- Start app for 3rd time and it works the same as the 2nd time.
- If I stop the first instance and start a new one it works like the first instance.
P.S. I do know this question must have been asked more then once, but google and StackOverflow search give me links only relative to Singleton Design Pattern.