Created
May 16, 2018 08:09
-
-
Save retran/a86b87f9a99b28008d2d075cbcf661b1 to your computer and use it in GitHub Desktop.
works on 64-bit cpu but fails on 32-bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
class MainClass { | |
public static void Main (string[] args) | |
{ | |
for (int i = 0; i < 10000; i++) | |
{ | |
long value = 0; | |
var t1 = Task.Run(() => | |
{ | |
for (int j = 0; j < 100; j++) | |
{ | |
value = 0x111111111; | |
} | |
}); | |
var t2 = Task.Run(() => | |
{ | |
for (int j = 0; j < 100; j++) | |
{ | |
value = 0x000000000; | |
} | |
}); | |
Task.WaitAll(t1, t2); | |
if (value != 0x000000000 && value != 0x111111111) | |
{ | |
throw new Exception("WTF?!"); | |
} | |
else | |
{ | |
Console.WriteLine(value); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment