List of usage examples for java.util Timer Timer
public Timer(String name)
From source file:Blocked.java
public static void main(String[] args) { new Timer(true).schedule(new TimerTask() { public void run() { System.out.println("Preparing to interrupt"); blocked.interrupt();/*from www . j a va2s. co m*/ blocked = null; // to release it } }, 2000); // run() after 2000 milliseconds }
From source file:CanStop.java
public static void main(String[] args) { final CanStop stoppable = new CanStop(); stoppable.start();/*from w w w.j ava 2 s . c om*/ new Timer(true).schedule(new TimerTask() { public void run() { System.out.println("Requesting stop"); stoppable.requestStop(); } }, 500); // run() after 500 milliseconds }
From source file:Main.java
public static void startTimer(TimerTask task, long interval) { final long IMMEDIATELY = 0; Timer timer = new Timer(true); timer.schedule(task, IMMEDIATELY, interval); }
From source file:MyTask.java
public Main() { timer = new Timer(true); }
From source file:JTop.java
public static void main(String[] args) throws Exception { // Validate the input arguments if (args.length != 1) { usage();/*from www . j a v a2 s . co m*/ } String[] arg2 = args[0].split(":"); if (arg2.length != 2) { usage(); } String hostname = arg2[0]; int port = -1; try { port = Integer.parseInt(arg2[1]); } catch (NumberFormatException x) { usage(); } if (port < 0) { usage(); } // Create the JTop Panel final JTop jtop = new JTop(); // Set up the MBeanServerConnection to the target VM MBeanServerConnection server = connect(hostname, port); jtop.setMBeanServerConnection(server); // A timer task to update GUI per each interval TimerTask timerTask = new TimerTask() { public void run() { // Schedule the SwingWorker to update the GUI jtop.newSwingWorker().execute(); } }; // Create the standalone window with JTop panel // by the event dispatcher thread SwingUtilities.invokeAndWait(new Runnable() { public void run() { createAndShowGUI(jtop); } }); // refresh every 2 seconds Timer timer = new Timer("JTop Sampling thread"); timer.schedule(timerTask, 0, 2000); }
From source file:de.nava.informa.utils.FeedRefreshDaemon.java
public FeedRefreshDaemon() { logger.info("FeedRefresh Daemon instancied"); this.refreshTimer = new Timer(true); }
From source file:FileMonitor.java
private FileMonitor() { timer = new Timer(true); timerTasks = new Hashtable<String, TimerTask>(); }
From source file:HRTimer.java
private HRTimer() { hrTimer = new Timer(true); }
From source file:FileMonitor.java
/** * Constructor.// w ww . j av a2 s. com */ private FileMonitor() { // Create timer, run timer thread as daemon. timer = new Timer(true); timerEntries = new Hashtable<String, FileMonitorTask>(); }
From source file:dev.maisentito.suca.commands.TimerCommandHandler.java
public TimerCommandHandler(Bundle globals) { super(globals); mTimer = new Timer(TimerCommandHandler.class.getSimpleName()); mTasks = Collections.synchronizedList(new LinkedList<UserTimer>()); }