开发者

Lock system in java application

I am doing simple rmi application.since it has server I want to lock jav开发者_开发技巧a application when it is ideal. Is there any convent way to apply lock system in java


There are two approaches I can think of.

  1. If it's all stand alone applications on the same computer, just create an empty file on disk when you start running, and any other instance attempting to start should look for the same file and if it exists, exit.

  2. If you can't share a "lock" file described above then can you set a record in a database table? All instances could check for the record existing (timestamp?) and then act accordingly.

Either way you need a central shared resource to act as a lock


I'm not sure if I understand your question. If it's about running single instance of an application, check out this: How to implement a single instance Java application?

Otherwise, if it's related to security, you should precise what are you trying to achieve.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜