Java - Ensure duplicate application instances can't run

Here is a nice little function that I wrote to ensure that duplicate instances of the same application cannot be run. This function relies on file locking instead of the more obvious route of using process ids. This is because process ids are actually platform dependent in java. Even though file locks are not mandatory (locking a file won't necessarily stop other applications from editing it), it still works for this functionality across platforms.

No comments:

Post a Comment