Concurrency 如何在ZooKeeper中实现互斥或对象监视器?

Concurrency 如何在ZooKeeper中实现互斥或对象监视器?,concurrency,mutex,apache-zookeeper,Concurrency,Mutex,Apache Zookeeper,我想使用ZooKeeper public class ResourceMonitor implements Watcher { String name = "/zk_test3"; ZooKeeper zk; public ResourceMonitor() throws IOException { zk = new ZooKeeper("localhost:8000", 3000, this); } public void w

我想使用
ZooKeeper

    public class ResourceMonitor implements Watcher {
    String name = "/zk_test3";
    ZooKeeper zk;

    public ResourceMonitor() throws IOException {
        zk = new ZooKeeper("localhost:8000", 3000, this);
    }

    public void waitAndGet() {

    }

    public void release() {
        //remove children
    }

    public void process(WatchedEvent event) {
        System.out.println("ResourceMonitor:" + event.toString());
    }
}

我是ZooKeeper的新手,在ZooKeeper收据中没有找到这样的例子。

您可以在上找到分布式锁实现的例子。
此外,您还可以查看zookeeper客户端,它具有的实现。

您可以在中找到分布式锁实现的示例。
另外,您可以看看zookeeper客户端,它实现了。

您是否可以扩展您的用例,它听起来非常像分布式锁,并且有一个可用的配方是的,似乎是相同的概念。您是否可以扩展您的用例,它听起来非常像分布式锁,并且有一个可用的配方是的,似乎是相同的概念。