The reason this is effective is because you can't delete a value unless you lock it and the value before it. That way, if one thread is locking 10, 11, then another thread can't delete 10 or 11 because they are locked by the first thread. It can't delete 18, because it can't get a lock to 11. It can delete 3 or 5, because it can "rewire" it to the according next number.
rubensan
One way to further understand hand-over-hand locking is that by locking the node with value 11, we are essentially locking the node with value 18 as well. This is because modifying 18 is dependent on locking 11. This dependency that 18 has on 11 has made it easier to understand one of the midterm questions.
The reason this is effective is because you can't delete a value unless you lock it and the value before it. That way, if one thread is locking 10, 11, then another thread can't delete 10 or 11 because they are locked by the first thread. It can't delete 18, because it can't get a lock to 11. It can delete 3 or 5, because it can "rewire" it to the according next number.