Hello I have this custom TimerTask :
public class TimerTaskPerso extends TimerTask {
private static boolean i = false;
@Override
public void run() {
System.out.println(i);
if(i){
System.out.println("m here");
return;
}
i= true;
System.out.println("ok");
try {
Thread.sleep(3000);
} catch (InterruptedException ignored) {
}
System.out.println("bye");
i= false;
}
}
And I am calling it like that :
new Timer().schedule(new TimerTaskPerso(), 1,500);
But the task keeps showing :
false
ok
bye
false
ok
false
I am supposed to see "m here" message, I tried this without creating Custom TimerTask and by using AtomicBoolean but same result.
Thanks in advance,