Skip to content

Instantly share code, notes, and snippets.

@renestein
Created June 16, 2011 18:11
Show Gist options
  • Save renestein/1029851 to your computer and use it in GitHub Desktop.
Save renestein/1029851 to your computer and use it in GitHub Desktop.
//Stupid "Schrodinger sort (cat not involved!)" based on http://dis.4chan.org/read/prog/1295544154 - great antipattern
static void Main(string[] args)
{
int[] xs = new[] { 5, 3, 6, 3, 6, 3, 1, 4, 7};
var results = new ConcurrentQueue<int>();
Console.WriteLine("Sorted:");
Parallel.ForEach(xs, n =>
{
Thread.SpinWait(n); //Thread.Sleep(n);
results.Enqueue(n);
}
);
results.ToList().ForEach(n => Console.WriteLine(n));
Console.ReadLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment