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");
}
}
}
After running this program multiple times there are differences and discrepancies:
Usually:
JAVA Develper
JAVA Develper
And occasionally:
JAVA Develper
JAVA Test
I am horrified by this. Where did I go wrong?