Description
"We consider two threads T1 and T2, which call the releaseCopy method. They both
read the state of the Entry object and create a new state object nstate, which is Idle.
Let's assume that the thread T1 executes the compareAndSet operation first and
returns the old Copying object c from the releaseCopy method. Next, let's assume
that a third thread T3 calls the acquireCopy method and changes the state of the
Entry object to Copying(1). If the thread T1 now calls the acquireCopy method
with the old Copying object c, the state of the Entry object becomes Copying(2).
Note that at this point, the old Copying object c is once again stored inside the atomic
variable state. If the thread T1 now attempts to call compareAndSet, it will succeed
and set the state of the Entry object to Idle. Effectively, the last compareAndSet
operation changes the state from Copying(2) to Idle, so one acquire is lost."
Please correct me If I'm wrong.
- As two threads T1 and T2 are in copying state the Entry object will be Entry(state = Copying(n=2)), so T1 or T2 will set nstate = Copying(n = 1) instead of Idle
- It should be thread T2 [which attemts to call compareAndSet] instead of T1