Java 这个代码有什么错误 类thread123扩展线程{ 公共线程123(int-ind,int-interval){ i0=ind; 延迟=间隔; } 公开募捐{ 试一试{ 对于(int i=1;i thread123 t2=new thread123(2,3.0);无效,因为thread123只接受ints delay=interval;无效,因为delay未定义,因此与delay有关的任何内容都与此相关 }否则,如果(i0=2){是和赋值,而不是评估,这不等同于布尔值,那么这是无效的 System.out.println(“n=“+i+”,Time=“+(delay*i-delay)+”,线程三:“+(18*(i*i)-12)/(i-2);缺少关闭)
您可能还希望通读,这将使人们更容易阅读您的代码,您也更容易阅读他人代码转储不会产生问题。您能解释一下您的预期结果是什么以及您的实际结果是什么吗?Java 这个代码有什么错误 类thread123扩展线程{ 公共线程123(int-ind,int-interval){ i0=ind; 延迟=间隔; } 公开募捐{ 试一试{ 对于(int i=1;i thread123 t2=new thread123(2,3.0);无效,因为thread123只接受ints delay=interval;无效,因为delay未定义,因此与delay有关的任何内容都与此相关 }否则,如果(i0=2){是和赋值,而不是评估,这不等同于布尔值,那么这是无效的 System.out.println(“n=“+i+”,Time=“+(delay*i-delay)+”,线程三:“+(18*(i*i)-12)/(i-2);缺少关闭),java,multithreading,extends,Java,Multithreading,Extends,您可能还希望通读,这将使人们更容易阅读您的代码,您也更容易阅读他人代码转储不会产生问题。您能解释一下您的预期结果是什么以及您的实际结果是什么吗?}否则,如果(i0=2){看起来可疑 class thread123 extends Thread { public thread123(int ind, int interval) { i0 = ind; delay = interval; } public void run() {
}否则,如果(i0=2){
看起来可疑
class thread123 extends Thread {
public thread123(int ind, int interval) {
i0 = ind;
delay = interval;
}
public void run() {
try {
for (int i = 1; i <= 10; i++) {
if (i0 == 1) {
System.out.println("n = " + i + ", Time = " + (delay * i - delay) + ", Thread one: " + (2 * i + 5));
} else if (i0 = 2) {
System.out.println("n = " + i + ", Time = " + (delay * i - delay) + ", Thread Two: " + (i + 10) * 2);
} else {
System.out.println("n = " + i + ", Time = " + (delay * i - delay) + ", Thread Three: " + (18 * (i * i) - 12) / (i - 2);
}
sleep(delay);
}
} catch (InterruptedException e) {
return;
}
}
private int i0;
}
class Threads {
public static void main(String[] args) throws InterruptedException {
thread123 t1 = new thread123(1, 20);
thread123 t2 = new thread123(2, 3.0);
thread123 t3 = new thread123(3, 40);
t1.start();
t2.start();
t3.start();
t1.join();
t2.join();
t3.join();
System.out.println("Main thread done");
}
}