Reputation: 15598
I have a List object in my class and two methods which are used to add and remove items from the list.
There are multiple threads trying to access the list.
What is the best mechanism to achieve this goal?
Upvotes: 2
Views: 198
Reputation: 7203
ReaderWriterLock object will be a good fit - allows for parallel reads but will block all the other threads while one thread is writing to the collection.
Upvotes: 1
Reputation: 9265
This is a multithreaded producer/consumer pattern. Take a look at this question.
Upvotes: 2