I am new to the concept of multithreading and have been exploring some interesting issues to better understand.
One of my friends suggested the following:
"Itβs quite simple to have a linked list and perform the usual operations of inserting, searching and deleting. But how will you perform these operations if several threads must work in one list. How many locks are required at least. How many locks can we have optimized functions of linked lists?"
Thinking, I feel that one lock should be enough for work. We get a lock for each read and write operation. By this, I mean that when we access the node data in a list, we acquire a lock. When we insert / remove elements, we get a lock for a whole series of steps.
But I could not think about how using more locks would give us more optimized performance.
Any help / pointers?
source
share