Skip to content

Instantly share code, notes, and snippets.

@retran
Created May 16, 2018 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retran/a86b87f9a99b28008d2d075cbcf661b1 to your computer and use it in GitHub Desktop.
Save retran/a86b87f9a99b28008d2d075cbcf661b1 to your computer and use it in GitHub Desktop.
works on 64-bit cpu but fails on 32-bit
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