List of usage examples for java.util Timer schedule
public void schedule(TimerTask task, Date firstTime, long period)
From source file:Main.java
public static void main(String[] args) { class SayHello extends TimerTask { Main thisObj = new Main(); public void run() { String todaysdate = thisObj.CurrentDate(); System.out.println(todaysdate); }/* w ww.ja v a 2 s . co m*/ } Timer timer = new Timer(); timer.schedule(new SayHello(), 0, 5000); }
From source file:MainClass.java
public static void main(String[] args) { Timer timer = new Timer(); timer.schedule(new DisplayQuestionTask(), 0, 10 * 1000); try {/*from www . j av a 2 s . c o m*/ Thread.sleep(10000); } catch (InterruptedException e) { } timer.cancel(); }
From source file:Main.java
public static void main(String[] args) { cb = new CyclicBarrier(2); Timer t = new Timer(); t.schedule(new MyTimerTask(cb), 1000, 1000); while (true) { try {/*from w w w . jav a 2 s .c om*/ cb.await(); } catch (Exception e) { } System.out.println("main"); } }
From source file:AutoTask.java
public static void main(String args[]) { AutoTask myTask = new AutoTask(); Timer bkTimer = new Timer(); bkTimer.schedule(myTask, 2000, 2000); for (int i = 0; i < 5; i++) { try {//from w w w.j a v a2 s . c o m Thread.sleep(2100); } catch (InterruptedException exc) { } } bkTimer.cancel(); }
From source file:GCTask.java
public static void main(String[] args) { Timer timer = new Timer(); GCTask task = new GCTask(); timer.schedule(task, 5000, 5000); int counter = 1; while (true) { try {/* ww w . j a v a 2 s . c o m*/ Thread.sleep(500); } catch (InterruptedException e) { } } }
From source file:MyTimerTask.java
public static void main(String[] args) { // creating timer task, timer TimerTask tasknew = new MyTimerTask(); Timer timer = new Timer(); // scheduling the task at interval timer.schedule(tasknew, 100, 100); }
From source file:MyTimerTask.java
public static void main(String[] args) { // creating timer task, timer TimerTask tasknew = new MyTimerTask(); Timer timer = new Timer(); // scheduling the task at interval timer.schedule(tasknew, new Date(), 1000); }
From source file:org.osbo.configuration.test.PruebaProperties.java
/** * @param args the command line arguments *//*w ww . j a va 2 s . c o m*/ public static void main(String[] args) { Timer timer = new Timer("Printer"); leerParameter t = new leerParameter(); timer.schedule(t, 0, 2000); }
From source file:eu.finesce.emarketplace.core.Scilab2OrionTimer.java
public static void main(String[] args) throws InterruptedException { String currentTime = null;/*from ww w .j ava 2 s. c o m*/ // Scilab2Orion rtlab2Orion = new Scilab2Orion("scilab2orion.properties", currentTime); // Timer timer = new Timer(); //to schedule every 15mins // timer.schedule(rtlab2Orion, 0, 900000); //call every 15 min }
From source file:MyTimerTask.java
public static void main(String args[]) { MyTimerTask myTask = new MyTimerTask(); Timer myTimer = new Timer(); /*/*from ww w. ja v a 2s . co m*/ * Set an initial delay of 1 second, then repeat every half second. */ myTimer.schedule(myTask, 1000, 500); try { Thread.sleep(5000); } catch (InterruptedException exc) { } myTimer.cancel(); }