此代码从不同的蒸汽数据中读取数字,并输出总和。这段代码有问题吗?我该如何解决?
public class Thr extends Thread{
static int numThr=100, sum=0;
private int num;
private Thr(int num){this.num =num;}
public void run() {
int k = IntegerReader.get(num);
int count=0;
while(k>0) {
if(count%numThr==num) sum+=k;
count++;
k=IntegerReader.get(num);
}
}
public static void main(String[] a) throws Exception {
thr[] st =new thr[numThr];
for(int i=0; i<numThr; i++) st[i] = new Thr(i);
for(int i=0; i<numThr; i++) st[i].start();
System.out.println("sum = "+sum);
}
}