几个线程安全的集合,使用其无需加锁

 BlockingCollection<string> bc = new BlockingCollection<string>();//为实现 System.Collections.Concurrent.IProducerConsumerCollection`1 的线程安全集合提供阻塞和限制功能。
            ConcurrentBag<int> cb = new ConcurrentBag<int>();//线程安全的无序集合
            ConcurrentQueue<int> queue = new ConcurrentQueue<int>();//先进先出的集合-队列
            ConcurrentStack<int> stack = new ConcurrentStack<int>();//先进后出的集合---先进货花了10元,后进货花了8元,你的货值多少钱?

猜你喜欢

转载自blog.csdn.net/qq_35534449/article/details/82180459