Skip to content

Instantly share code, notes, and snippets.

@dested
Created June 27, 2017 18:45
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 dested/639f9306e47f46cc8ce7db484fc7fd1e to your computer and use it in GitHub Desktop.
Save dested/639f9306e47f46cc8ce7db484fc7fd1e to your computer and use it in GitHub Desktop.
var locker = new object();
long count1 = 0,count2=0;
Task.Run(() =>{while (true)lock (locker)count1++;});
Task.Run(() =>{while (true)lock (locker)count2++;});
Task.Run(() =>{while (true)Console.WriteLine(" Diff :" + (count1 - count2));});
Console.ReadLine();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment