Fig. 7.33 shows an alternative implementation of
CLHLock in which a thread reuses its own node instead of its
predecessor node. Explain how this implementation can go wrong.
```
public class BadCLHLock implements Lock {
// most recent lock holder
AtomicReference<Qnode> tail = new Qnode();
// thread-local variable
ThreadLocal<Qnode> myNode;
public void lock() {
Qnode qnode = myNode.get();
qnode.locked = true; || I'm not done
// Make me the new tail, and find my predecessor
Qnode pred = tail.getAndSet(qnode);
// spin while predecessor holds lock
while (pred.locked) {}
}
public void unlock() {
// reuse my node next time
myNode.get().locked = false;
}
static class Qnode { // Queue node inner class
public boolean locked = false;
}
}
```