Is one-insert-multi-read list safe without lock?

I have a problem about synchronization between threads. I know the normal synchronization method and lock-free list. But I have a strange (maybe) idea.

I have a normal singly list, linked by next pointer.

There is only 1 thread who just insert items into this list, but never delete items. The way to add item:

new_item->next = list_head;
list_head = new_item;

There are some other threads who just traverse this list (read only).

There is no lock at all.

I think that this should be safe, because the read-only-threads will never get an invalid pointer. Am I right?

I do not know how to search this on internet. What I get is all about lock-free list by CAS or something. So I ask it here.

Thanks in advance

Miner Asked on February 28, 2018 in General Stack.
Add Comment


  • LATEST ANSWERS

  • 0 Answer(s)

    Write your answer

    By posting your answer, you agree to the privacy policy and terms of service.