Does my Dictionary must use locking mechanism?
Posted
by
theateist
on Stack Overflow
See other posts from Stack Overflow
or by theateist
Published on 2012-06-17T15:09:57Z
Indexed on
2012/06/17
15:16 UTC
Read the original article
Hit count: 253
Many threads have access to summary
. Each thread will have an unique key for accessing the dictionary;
Dictionary<string, List<Result>> summary;
Do I need locking for following operations?
summary[key] = new List<Result>()
summary[key].Add(new Result());
It seems that I don't need locking because each thread will access dictionary with different key, but won't the (1) be problematic because of adding concurrently new record to dictionary with other treads?
© Stack Overflow or respective owner