I need timer that is going to make pause in running of main thread.
Like Thread.sleep() does,just I don't want to create Exceptions like this does.
So I want to use Timer class. "java.util.Timer;" this one.
I want to make class and to use her constructor where I need pause,like this:
some code;
//I need pause of 10 secunds hier
MakePauseClass x= new MakePauseClass(10);
some code;
I guess I can tweak this code to achieve this:
I guess I should make different void run() method...
import java.util.Timer;
import java.util.TimerTask;
public class MakePauseClass{
Timer timer;
public MakePauseClass(int seconds) {
timer = new Timer();
timer.schedule(new RemindTask1(), seconds*1000);
}
class RemindTask1 extends TimerTask {
public void run() {
System.out.format("Time's up!%n");
timer.cancel(); //Terminate the timer thread
}
}
}