static void Main(string[] args) { var worker = new Worker(); ConcurrentBag <string> results = new ConcurrentBag <string>(); //var threads = new List<Thread>(); Enumerable.Range(1, 10) .Select(t => new Thread(_ => { results.Add(worker.Run(1000)); })) .ToList() .Select(t => { t.Start(); return(t); }) .For(t => t.Join()); results.For(x => Console.WriteLine(x)); Console.WriteLine("Starting"); Enumerable .Range(1, 10) .Select(_ => new Future <string>(() => worker.Run(1000))) .ToList() .Select(w => w.GetResult()) .For(x => Console.WriteLine(x)); // var opt = new ParallelOptions { MaxDegreeOfParallelism = 20 }; // Parallel.For(0, 10, opt, _ => worker.Run()); /* * Enumerable.Range(1, 10) * .Select(_ => new Thread(worker.Run)) * .Select(t => * { * t.Start(); * return t; * }) * .ToList() * .ForEach(t => t.Join()); * * for (int i = 0; i < 10; i++) * { * var thread = new Thread(_ => worker.Run()); * threads.Add(thread); * thread.Start(); * } * * foreach (var thread in threads) * thread.Join(); */ Console.WriteLine("Done"); Console.ReadKey(true); }