Skip to content

Instantly share code, notes, and snippets.

@yuessir
Last active November 9, 2018 10:13
Show Gist options
  • Save yuessir/80b65518734eeb87f5e139f59a24e719 to your computer and use it in GitHub Desktop.
Save yuessir/80b65518734eeb87f5e139f59a24e719 to your computer and use it in GitHub Desktop.
Using C# Thread.Sleep to Sort Array Ascending For FUN XDDDDDD
private static void Main(string[] args)
{
int[] nums = new int[] { 13, 3, 889, 5455, 1, 152, 990 };
ParameterizedThreadStart myPar = new ParameterizedThreadStart(SleepSort);
foreach (var num in nums)
{
Thread myThread = new Thread(myPar);
myThread.IsBackground = true;
myThread.Start(num);
}
Console.ReadKey();
}
public static void SleepSort(object i)
{
Thread.Sleep(Convert.ToInt32(i));
Console.WriteLine(Convert.ToInt32(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment