public class TenThreads {
private static class WorkerThread extends Thread {
int max = Integer.MIN_VALUE;
int[] ourArray;
public WorkerThread(int[] ourArray) {
this.ourArray = ourArray;
}
// Find the maximum value in our particular piece of the array
public void run() {
for (int i = 0; i < ourArray.length; i++)
max = Math.max(max, ourArray[i]);
}
public int getMax() {
return max;
}
}
public static void main(String[] args) {//====================
WorkerThread[] threads = new WorkerThread[10];
int[][] bigMatrix = getBigHairyMatrix();
//==================问题在这里啦! 
int max = Integer.MIN_VALUE;
// Give each thread a slice of the matrix to work with
for (int i=0; i < 10; i++) {
threads[i] = new WorkerThread(bigMatrix[i]);
threads[i].start();
}
// Wait for each thread to finish
try {
for (int i=0; i < 10; i++) {
threads[i].join();
max = Math.max(max, threads[i].getMax());
}
}
catch (InterruptedException e) {
// fall through
}
System.out.println("Maximum value was " + max);
}
}
==============================================================
WorkerThread[] threads = new WorkerThread[10];
int[][] bigMatrix = getBigHairyMatrix();
我想请问一下:int[][] bigMatrix = getBigHairyMatrix();
getBigHairyMatrix() 是什么意思啊 什么作用啊

解决方案 »

  1.   

    getBigHairyMatrix() 代码找不到。
      

  2.   

    bigMatrix 是int 型二维数组指针,getBigHairyMatrix()  这个鬼才知道是做啥的。
      

  3.   

    lz是从网上摘来的例子吧?getBigHairyMatrix()这个方法根本没有
      

  4.   

     是啊 从网上找的 我看的时候怎么看了一次又一次 返回去看 再百度 怎么就是没有getBigHairyMatrix().....我就愣住了。
      

  5.   

    傻傻的告诉你 getBigHairyMatrix 是个返回 int二维数组的方法
      

  6.   

     哥们能讲讲吗?? 你讲的和书里说的有点意思。Come on.
      

  7.   

    我看的这书就是讲加锁的,搞的我头晕眼花......突然来了getBigHairyMatrix()  直接崩溃
      

  8.   

    大哥 不是偷啦 初学者 在网上下载的PDF东东  看到有问题就扔这里求大家帮忙解决啦啦
      

  9.   

    public static int[][] getBigHairyMatrix() {
    int[][] martrix= {
              {1,2,3},{3,4,5},
              {5,6,7},{7,8,9},
              {9,10,11},{11,12,13},
              {13,14,15},{15,16,17},
              {17,18,19},{19,20,21}
              };
              

    return martrix;
    }
    其实就是少了个二维数组嘛~~加上就好啦~