fork download
  1. using System;
  2. using System.Diagnostics;
  3. using System.Threading.Tasks;
  4.  
  5. class Program {
  6. static volatile int s_x;
  7. static volatile int s_xa;
  8. static volatile int s_y;
  9. static volatile int s_ya;
  10.  
  11. static void Main(string[] args) {
  12. while (true) {
  13. s_x = 0; s_xa = 0; s_y = 0; s_ya = 0;
  14. Task A = Task.Factory.StartNew(() => {
  15. s_x = 1; // W
  16. s_ya = s_y; // W, R
  17. });
  18. Task B = Task.Factory.StartNew(() => {
  19. s_y = 1; // W
  20. s_xa = s_x; // W, R
  21. });
  22. Task.WaitAll(A, B);
  23. if (!(s_xa == 1 || s_ya == 1)) Console.WriteLine("* {0}, {1}", s_xa, s_ya);
  24. }
  25. }
  26. }
  27.  
  28.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(3,24): error CS0234: The type or namespace name `Tasks' does not exist in the namespace `System.Threading'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty