multithreading - An ambiguity in the documentation on threading in C# -


while reading joe albahari's excellent book "threading in c#" came across following ambiguous sentence:

a thread-safe type not make program using thread-safe, , work involved in latter makes former redundant.

(you can find sentence on this page; search "indeterminacy" jump appropriate section.)

i looking use concurrentdictionary implement thread-safe data structures. paragraph telling me concurrentdictionary not guarantee thread-safe writes data structure? can please provide counter-example shows thread-safe type failing provide thread safety?

thanks in advance help.

at simplest, thread safe list or dictionary example; having each individual operation thread safe isn't enough - example, "check if list empty; if is, add item" - if thread-safe, can't do:

if(list.count == 0) list.add(foo); 

as change between two. need synchronize test and change.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -