java多线程并发编程之创新排序法-睡眠排序大法,多线程并发排序使得排序效率更高
public class sleepSort {
public static void main(String[] args) {
int[] num=new int[]{1,45,28,63,77,62};
sleepSort(num);
}
public static void sleepSort(int[] num){
for (int i=0;i<num.length;i++){
int number=num[i];
new Thread(()->{
try {
Thread.sleep(number);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(number);
}).start();
}
}
}