Hello I want to make a if statement in JAVA, that..if thread is not running, we pressed a shortkey and the Thread start running, and if the thread is running, we pressed the same shortkey and the Thread stops running.
My code:
if(!th.isAlive()){
th.start();
}else{
th.stop();
}
But doesn't work this code. Please help me.
p.s - This if statement happens when click in shortkey