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

C#多线程之睡眠排序

这个太吊了

不想多说了

让我先笑会

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

下面代码引入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 (); //开始线程
}
}
}
}

本文标题:天才算法之睡眠排序(C#实现)

文章作者:yiny

发布时间:2019年02月13日 - 13:02

最后更新:2019年02月16日 - 20:02

原始链接:https://blog.yiny.ml/2019/02/13/SleepSort-C/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

0%