What is better and why to use List as thread safe: BlockingCollection or ReaderWriterLockSlim or lock?
Posted
by
theateist
on Stack Overflow
See other posts from Stack Overflow
or by theateist
Published on 2012-06-04T10:28:19Z
Indexed on
2012/06/04
10:40 UTC
Read the original article
Hit count: 168
I have System.Collections.Generic.List _myList
and many threads can read from it or add items to it simultaneously. From what I've read I should using 'BlockingCollection' so this will work. I also read about ReaderWriterLockSlim' and 'lock', but I don't figure out how to use them instead of
BlockingCollection`, so my question is can I do the same with:
- ReaderWriterLockSlim
- lock
instead of using 'BlockingCollection'. If YES, can you please provide simple example and what pros and cons of using BlockingCollection
, ReaderWriterLockSlim
, lock
?
© Stack Overflow or respective owner