Skip to content

链表的变换是线程不安全吗? #1

@YapAmbition

Description

@YapAmbition

这个方案是不是会由于链表变换是线程不安全的而导致出错?例如LRU:

1. current.prev.next = current.next;
2. current.next.prev = current.prev;
3. moveToTail(current);

如果线程A执行完1, 线程B执行3, 那么当线程A再执行2的时候将直接把节点current之后的部分全部截去😐

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions