List of usage examples for java.util Timer purge
public int purge()
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 timer.scheduleAtFixedRate(tasknew, new Date(), 10); // cancel task timer.cancel();// w w w . ja v a 2 s. co m // purging the timer System.out.println("purge value :" + timer.purge()); }
From source file:com.offbynull.portmapper.common.ProcessUtils.java
/** * Run a process and dump the stdout stream to a string. * @param timeout maximum amount of time the process can take to run * @param command command//from w ww .ja v a2s .c o m * @param args arguments * @return stdout from the process dumped to a string * @throws IOException if the process encounters an error * @throws NullPointerException if any arguments are {@code null} or contains {@code null} * @throws IllegalArgumentException any numeric argument is negative */ public static String runProcessAndDumpOutput(long timeout, String command, String... args) throws IOException { Validate.notNull(command); Validate.noNullElements(args); Validate.inclusiveBetween(0L, Long.MAX_VALUE, timeout); String[] pbCmd = new String[args.length + 1]; pbCmd[0] = command; System.arraycopy(args, 0, pbCmd, 1, args.length); ProcessBuilder builder = new ProcessBuilder(pbCmd); final AtomicBoolean failedFlag = new AtomicBoolean(); Timer timer = new Timer("Process timeout timer", true); Process proc = null; try { proc = builder.start(); final Process finalProc = proc; timer.schedule(new TimerTask() { @Override public void run() { failedFlag.set(true); finalProc.destroy(); } }, timeout); String ret = IOUtils.toString(proc.getInputStream()); if (failedFlag.get()) { throw new IOException("Process failed"); } return ret; } finally { if (proc != null) { proc.destroy(); } timer.cancel(); timer.purge(); } }
From source file:edu.missouri.bas.service.SensorService.java
public static void PurgeTimers(Timer t) { //if(t1!=null&&t2!=null&&t3!=null&&t4!=null&&t5!=null&&t6!=null&&mTimer!=null) if (t != null) { t.purge(); //mTimer.cancel(); }//from w ww .jav a2 s . com }
From source file:edu.missouri.bas.service.SensorService.java
public static void CancelTimers(Timer t) { //if(t1!=null&&t2!=null&&t3!=null&&t4!=null&&t5!=null&&t6!=null&&mTimer!=null) if (t != null) { t.cancel();/*w ww . j a v a 2 s. c o m*/ t.purge(); //mTimer.cancel(); } }
From source file:pt.lsts.neptus.plugins.controllers.ControllerManager.java
public void stop() { if (debug)//from ww w .ja v a2 s. co m System.out.println("Stopping all controller manager timers"); for (String v : activeControllers.keySet()) activeControllers.get(v).stopControlling(VehiclesHolder.getVehicleById(v)); activeControllers.clear(); for (Timer t : timers.values()) { t.cancel(); t.purge(); } timers.clear(); }
From source file:pl.openrnd.connection.rest.ConnectionHandler.java
private void stopRequestTimer(Timer timer) { if (timer == null) { return;/*w ww. j a va 2s. c o m*/ } timer.purge(); timer.cancel(); }
From source file:deincraftlauncher.IO.download.FTPDownloader.java
private void update() { System.out.println("downloader update #" + updateNum); updateNum++;//from www . ja v a 2 s . co m if (finished) { System.out.println("cancelling updating"); return; } onUpdate.call(totalProgress, totalSize, this); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { //periodic update timer.cancel(); timer.purge(); update(); } }, updateDelay); }
From source file:deincraftlauncher.IO.download.Downloader.java
private void update() { System.out.println("downloader update #" + updateNum); updateNum++;/*from www.java2 s . c om*/ if (instance.finished) { System.out.println("cancelling updating"); return; } onUpdate.call(totalProgress, totalSize, this); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { //periodic update timer.cancel(); timer.purge(); update(); } }, updateDelay); }
From source file:org.jwebsocket.util.Tools.java
/** * Starts the jWebSocket utility timer. The timer automatically purge expired tasks every 5 * minute.//from www .j a v a2 s .c o m */ public static void startUtilityTimer() { if (System.getProperties().contains("JWEBSOCKET_HOME")) { AccessController.checkPermission(stringToPermission( "permission java.util.PropertyPermission \"" + "org.jwebsocket.tools.timer\", \"write\"")); } if (null == mTimer) { mTimer = new Timer("jWebSocket Utility Timer"); final Timer lTimer = mTimer; mTimer.scheduleAtFixedRate(new JWSTimerTask() { @Override public void runTask() { lTimer.purge(); } }, 0, 300000); } }
From source file:de.thm.arsnova.services.QuestionService.java
@Override public void cancelDelayedPiRoundChange(final String questionId) { Timer timer = timerList.get(questionId); if (null != timer) { timer.cancel();//from w w w. j ava2 s. c om timerList.remove(questionId); timer.purge(); } }