static void Main(string[] args) { List<Task> tlist = new List<Task>(); var queue = ServiceContainer.GetQueue<Info>(); for (int j = 0; j < 3; j++) { for (int i = 0; i < 10; i++) { tlist.Add( Task.Run(() => { for (int z = 0;z < 10; z++) { queue.Enqueue(new Info() { Str = "DateTime:" + DateTime.Now.ToString() + "毫秒:" + DateTime.Now.Millisecond.ToString() + " ;Num:" + z.ToString() }); } ConsoleStr(queue, j); })); } Task.WaitAll(tlist.ToArray()); } System.Console.ReadKey(); } private static void ConsoleStr(IQueue<Info> queue, int j) { while (queue != null && !queue.IsEmpty) { Info i = null; var q = queue.TryDequeue(out i); if (q && i!= null) { System.Console.WriteLine(i.Str + "j:" + j.ToString()); } } }