Take the 2-minute tour ×
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It's 100% free, no registration required.

I asked a question on persistence data structure here. After that I came across an article on code project. I have got a question on the following figure from the same article:

enter image description here

The author says:

Inserting a new item into a persistent singly linked list will not alter the existing list but create a new version with the item inserted into it. Instead of copying the entire list and then inserting the item into the copy, a better strategy is to reuse as much of the old list as possible.

Now my doubt wrt to this idea is that since the two versions (Red and Yellow + Red), have common nodes (i.e last three Red nodes), how can one access these two versions simultaneously (for example in a multithreaded application)?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Such list is intended to be immutable - the shared nodes will never be written to. There is no problem with several threads reading from the same memory location.

share|improve this answer
add comment

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.