啥也不说了,一个非常牛逼的算法,复杂度是常数级别的。利用了多线程进行排序
public class NBSort {
public static void main(String[] args) {
int[] result = {33,66,1,44,7,9,0,88,16,31,69,26};
SortThread1[] threads = new SortThread1[result.length];
for(int i = 0;i<threads.length;i++){
threads[i] = new SortThread1(result[i]);
}
for(int i = 0;i<threads.length;i++){
threads[i].start();
}
}
}
class SortThread1 extends Thread{
public int param;
public SortThread1(int param){
this.param = param;
}
@Override
public void run() {
try {
sleep(param*10 + 10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(param+" ");
}
}
public class NBSort {
public static void main(String[] args) {
int[] result = {33,66,1,44,7,9,0,88,16,31,69,26};
SortThread1[] threads = new SortThread1[result.length];
for(int i = 0;i<threads.length;i++){
threads[i] = new SortThread1(result[i]);
}
for(int i = 0;i<threads.length;i++){
threads[i].start();
}
}
}
class SortThread1 extends Thread{
public int param;
public SortThread1(int param){
this.param = param;
}
@Override
public void run() {
try {
sleep(param*10 + 10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(param+" ");
}
}