When B wakes up the 1st thing it does is state.exchange(sleeper,…), which returns unlocked, and set the state to sleeper.
I think it works.
I had some concerns about the second one, but I think it works too…
I had some concerns about the second one, but I think it works too…