如何转换排序代码以并行执行

for (int i=0; i<b.size() ; i++){
          int lowestId = -1;
          double lowestvalue = Double.MAX_VALUE;
          for (int k=0 ; k<b.size() ; k++) {
              if (c[k] < lowestvalue){
                  lowestId = k;
                  lowestvalue = cPower[k];
              }
          }
          sortedonvalue[i] = lowestId;
          c[lowestId] = Double.MAX_VALUE;
      }
任何想法如何使此代码并行执行
评论
情癌晚期
情癌晚期
Thread t1=new Thread() {
   public void run() {
       for (int i=0; i<b.size() ; i++){
          int lowestId = -1;
          double lowestvalue = Double.MAX_VALUE;
          for (int k=0 ; k<b.size() ; k++) {
              if (c[k] < lowestvalue){
                  lowestId = k;
                  lowestvalue = cPower[k];
              }
          }
          sortedonvalue[i] = lowestId;
          c[lowestId] = Double.MAX_VALUE;
      }
   }
};
t1.start();
点赞
评论