fork download
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10.  
  11. namespace TestTestTest
  12. {
  13. class Program
  14. {
  15. static void Main(string[] args)
  16. {
  17. var list = new SortedList<string, FileInfo>();
  18. foreach (var name in Directory.GetFiles("C:\\WINDOWS"))
  19. {
  20. list.Add(name, new FileInfo(name));
  21. }
  22.  
  23. Action a = () =>
  24. {
  25. while (true)
  26. {
  27. foreach (var kvp in list)
  28. {
  29. Console.WriteLine("Action=A:{0}", kvp.Value.Name);
  30. }
  31. }
  32. };
  33.  
  34. Action b = () =>
  35. {
  36. while (true)
  37. {
  38. for (int i = 0; i < list.Count; i++)
  39. {
  40. Console.WriteLine("Action=B:{0}", list[list.Keys[i]].Name);
  41. }
  42. }
  43. };
  44.  
  45. for (int i = 0; i < 25; i++ )
  46. {
  47. Task.Factory.StartNew(a);
  48. Task.Factory.StartNew(b);
  49. }
  50. Thread.Sleep(600 * 1000);
  51. }
  52. }
  53. }
  54.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty