天才算法之睡眠排序(C#实现)

5 年前(已编辑)
1145
这篇文章上次修改于 3 年前,可能部分内容已经不适用,如有疑问可询问作者。

C#多线程之睡眠排序

这个太吊了

不想多说了

让我先笑会

我也会写睡眠算法了。哈哈哈嗝~

下面代码引入

using System;
using System.Threading;
namespace SleepSort {
    class SleepSortMainEntence {
        static void Main (string[] args) {
            int[] a = new int[] { 123, 243, 32, 443, 72, 3 };
            foreach (var item in a) {  // 遍历数组
                Thread th = new Thread (x => {
                    Thread.Sleep (item * 10); //睡眠时间,时间越短,越不精确
                    System.Console.WriteLine (item); // 睡完输出
                });
                th.Start ();  //开始线程
            }
        }
    }
}
评论区加载中...