Java synchronization between different JVMs

前端 未结 5 1126
醉话见心
醉话见心 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 00:52

    You can use synchronized keyword, locks, atomic objects, etc. - but they are local to the JVM. So if you have two JVMs running the same program, they can still e.g. run the same synchronized method at the same time - one on each JVM, but not more.

    Solutions:

    • terracotta provides distributed locking

    • hazelcast as well

    • you can use manual synchronization on file system or database

提交回复
热议问题