Fix concurrent remove

This commit is contained in:
Him188 2020-02-02 19:56:46 +08:00
parent b38f82523f
commit ddae4c106a

View File

@ -132,7 +132,10 @@ open class LockFreeLinkedList<E> {
if (toRemove.isRemoved()) {
continue
}
toRemove.removed.value = true // logically remove: all the operations will recognize this node invalid
if (!toRemove.removed.compareAndSet(false, true)) {
// logically remove: all the operations will recognize this node invalid
continue
}
// physically remove: try to fix the link