Previous | Next --- Slide 8 of 37
Back to Lecture Thumbnails
nemo

Here, thread 2 assigns prev->next to cur->next (5 to 11) first. Thread 1 assigns prev->next to newly inserted node (5 to 6) just after that. Thread 2 deletes 10, and therefore the rest of the linked list is lost!

annag

Another possible result: thread 1 inserts 6 into the linked list. Thread 2 assigns the next pointer of 5 to 11, and then deletes 10. As a result, the insertion of 6 is lost.