Issue with Multithreading spin locks
Process B isn't looping; it runs and then quits. In other words, there won't be a second "leave note B" in your picture. There is a loop in process A (a busy wait, as it's called) and when process B removes its note, then execution will return to A's loop: A will check and see that there is milk so will remove its note and quit.