Skip to content

Instantly share code, notes, and snippets.

@smanek
Created November 14, 2011 22:48
Show Gist options
  • Save smanek/1365466 to your computer and use it in GitHub Desktop.
Save smanek/1365466 to your computer and use it in GitHub Desktop.
final int port = 2182;
final EmbeddedZookeeperServer server = EmbeddedZookeeperServer.builder().clientPort(port).build();
final RobustZooKeeper client = new RobustZooKeeper("localhost:" + port);
client.withLock("lockName",
new Runnable() {
@Override
public void run() {
System.out.println("I've got the lock while I'm running!");
}
});
client.shutdown();
server.shutdown();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment