Sharing a Java synchronized block across a cluster, or using a global lock?

前端 未结 5 1290
死守一世寂寞
死守一世寂寞 2021-02-01 07:14

I have some code that I want to only allow access to by one thread. I know how to accomplish this using either synchronized blocks or methods, but will this work i

5条回答
  •  攒了一身酷
    2021-02-01 07:32

    You can use a in-memory-data-grid like http://www.hazelcast.com/ for this too. This is a distributed data structure that supports locking.

提交回复
热议问题