开发者

How to check if two instances of the same java program are running?

Hi am making a program which will run through javaw.exe, so that it is not visible directly. Now my issue is sometime, (accidently) it can happen that the user runs multiple instances of the same application,

e.g entering javaw myProgram two times

Under such situation, is there any way i can prevent multiple instances of the same program to run if the program is already开发者_开发知识库 running.


Although file lock is probably the simplest and easiest option, I'd like to mention one alternative: JIntellitype is a library which works only on Windows and has the utility method to check if the application window with the given title is already running.

If it just so happens that you're OK with having this functionality only on Windows and using file lock doesn't work for you... :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜