Previous | Next --- Slide 32 of 66
Back to Lecture Thumbnails
Claire

1 problem is when two threads are inserting at the same time in the same place. The first thread that finishes will have their element be overwritten by the 2nd thread so that the link list will only have the 2nd thread's element in the list.

mziv

Another problem is if one thread delets while another thread is inserting. Consider the case where thread 1 is inserting at some index, let's say after some element A. It picks that spot as its location. Then, thread 2 comes in and deletes A. Thread 1 will then go on to write to the next pointer of A (now freed memory!) and we'll end up losing the insertion and leaking memory.

Please log in to leave a comment.