C# 安全队列

Queue myQ = new Queue();
myQ.Enqueue("The");
myQ.Enqueue("quick");
myQ.Enqueue("brown");
myQ.Enqueue("fox");

// 创建带锁读写器
Queue mySyncdQ = Queue.Synchronized(myQ);

// 队列状态
Console.WriteLine("myQ is {0}.", myQ.IsSynchronized ? "synchronized" : "not synchronized");
Console.WriteLine("mySyncdQ is {0}.", mySyncdQ.IsSynchronized ? "synchronized" : "not synchronized");

posted @ 2021-06-03 10:04  supersdar  阅读(143)  评论(0编辑  收藏  举报