Giriş
Şu satırı dahil ederiz
import com.hazelcast.cp.lock.FencedLock;
lock metodu
Örnek
Şöyle yaparız
HazelcastInstance hz =...; // Get a distributed lock called "my-distributed-lock" Lock lock = hz.getCPSubsystem().getLock("my-distributed-lock"); // Now create a lock and execute some guarded code. lock.lock(); try { //do something here } finally { lock.unlock(); }tryLock metodu
Örnek
Şöyle yaparız
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(); CPSubsystem cpSubsystem = hazelcastInstance.getCPSubsystem(); FencedLock lock = cpSubsystem.getLock("lock"); lock.tryLock();
Hiç yorum yok:
Yorum Gönder