public class suspendCheck extends Thread{
int t ;
public static void main(String args[]) throws InterruptedException {
suspendCheck as = new suspendCheck();
Thread t2 = new Thread(as);
t2.start();
Thread t3 = new Thread(as);
t3.start(); }
public void run(){
if(t==0){
System.out.println("JAVA Develper");
t= ++t;
}
else{
System.out.println("JAVA Test");
}
}
}
多次运行此程序后,存在差异和差异:
通常:
JAVA Develper
JAVA Develper
偶尔:
JAVA Develper
JAVA Test
我对此感到恐惧。我哪里做错了?