1 Star 0 Fork 454

鹏鹏大帅哥/bullshit-codes

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
SleepSort 725 Bytes
一键复制 编辑 原始数据 按行查看 历史
z77z 提交于 2019-05-29 17:05 +08:00 . 更新 SleepSort 注解
/**
* 睡觉排序法
*
* @author z77z
*
*/
public class SleepSort {
public static void main(String[] args) {
int[] ints = { 1, 4, 7, 3, 8, 9, 2, 6, 5 };
SortThread[] sortThreads = new SortThread[ints.length];
for (int i = 0; i < sortThreads.length; i++) {
sortThreads[i] = new SortThread(ints[i]);
}
for (int i = 0; i < sortThreads.length; i++) {
sortThreads[i].start();
}
}
}
class SortThread extends Thread {
int ms = 0;
public SortThread(int ms) {
this.ms = ms;
}
public void run() {
try {
sleep(ms * 10 + 10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(ms);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/peishuaige/bullshit-codes.git
git@gitee.com:peishuaige/bullshit-codes.git
peishuaige
bullshit-codes
bullshit-codes
master

搜索帮助