MCPcopy Create free account
hub / github.com/careercup/ctci / Chopstick

Class Chopstick

java/Chapter 16/Question16_3/Chopstick.java:6–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import java.util.concurrent.locks.ReentrantLock;
5
6public class Chopstick {
7 private Lock lock;
8
9 public Chopstick() {
10 lock = new ReentrantLock();
11 }
12
13 public boolean pickUp() {
14 return lock.tryLock();
15 }
16
17 public void putDown() {
18 lock.unlock();
19 }
20}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected