I wrote a simple app that runs on some time interval (ex. every 1 min.). That app get and put some files from a some FTP, connect to the Oracle DB etc.. I put that app on a Linux cron table and setup to run every minute. I don't wont cron to start app again before previous instance is finished. That is why I need to test if the previous instance is over before start the new one.
> What if several JVMs run on a given box, each of them
> having an instance of your singleton?
Amen. Singleton will absolutely not work to solve the OPs question. Regardless of whether the app is a "server" or not, it is still allowed to open a listener on a socket.
The only caveat here is that if you are running on a windows laptop that is not connected to the network, the server socket will fail (nice, eh?).
Another option is to use the nio API to create a lock file.
- K