Java synchronization between different JVMs

前端 未结 5 1074
醉话见心
醉话见心 2021-02-08 00:36

The project I am working on would trigger various asynchronous jobs to do some work. As I look into it more these asynchronous jobs are actually being run as separate JVMs (sepa

5条回答
  •  庸人自扰
    2021-02-08 01:06

    That's right. You can not use any standard synchronization mechanisms because they are working into one JVM.

    Solutions

    1. You can use file locks introduced in java 7.
    2. You can use synchronization via database entities.
    3. One of already implemented solutions like Terracota may be helpful
    4. Re-think your design. If you are beginner in java world try to talk in details with more experienced engineers. Your question shows that IMHO you are just on wrong way.

提交回复
热议问题