`
gaopengxiang417
  • 浏览: 21598 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论
阅读更多
啥也不说了,一个非常牛逼的算法,复杂度是常数级别的。利用了多线程进行排序
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+" ");
    }
   
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics