Is this combination of ConcurrentDictionary and ConcurrentQueue thread-safe?
问题 I'm using the ConcurrentDictionary and ConcurrentQueue classes from .NET 4 in the following code. Is this code thread-safe? If not, how can I make it thread-safe? public class Page { public string Name {get; set; } } public class PageQueue { private ConcurrentDictionary<int, ConcurrentQueue<Page>> pages = new ConcurrentDictionary<int, ConcurrentQueue<Page>>(); public void Add(int id, Page page) { if (!this.pages.ContainsKey(id)) this.pages[id] = new ConcurrentQueue<Page>(); this.pages[id]