Skip to content

Instantly share code, notes, and snippets.

@heebinho
Last active February 2, 2019 08:46
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 heebinho/a1d5655901902db3c5399ecf38c9681c to your computer and use it in GitHub Desktop.
Save heebinho/a1d5655901902db3c5399ecf38c9681c to your computer and use it in GitHub Desktop.
Mutating state from concurrent processes yields unpredictable results
var list = Enumerable.Range(-1000,2001).Reverse().ToList();
Action a1 = () => list.Sum().Dump();
Action a2 = () => { list.Sort(); list.Sum().Dump(); };
Parallel.Invoke(a1, a2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment