List of usage examples for java.util Timer Timer
public Timer(String name, boolean isDaemon)
From source file:com.sidekickApp.PusherClass.java
private void startInputTimer() { log("startInputTimer()"); inputTimer = new Timer("inputTimer", true); long initialDelay = 0; long interval = 2000; inputTimer.scheduleAtFixedRate(new TimerTask() { public void run() { // calculate decay interest = interest + numEvents * 50; numEvents = 0;/*from w ww . ja v a 2s .c om*/ } }, initialDelay, interval); }
From source file:de.tor.tribes.ui.windows.DSWorkbenchSplashScreen.java
/** * Creates new form DSWorkbenchSplashScreen */// w w w . ja v a 2 s . c o m DSWorkbenchSplashScreen() { initComponents(); if (GlobalOptions.isMinimal()) { jLabel1.setIcon(new ImageIcon("./graphics/splash_mini.gif")); } else { jLabel1.setIcon(new ImageIcon("./graphics/splash.gif")); } setTitle("DS Workbench " + Constants.VERSION + Constants.VERSION_ADDITION); jProfileDialog.getContentPane().setBackground(Constants.DS_BACK_LIGHT); jProfileDialog.pack(); jProfileDialog.setLocationRelativeTo(DSWorkbenchSplashScreen.this); t = new SplashRepaintThread(); t.start(); new Timer("StartupTimer", true).schedule(new HideSplashTask(), 1000); }
From source file:mondrian.util.UtilCompatibleJdk15.java
public Timer newTimer(String name, boolean isDaemon) { return new Timer(name, isDaemon); }
From source file:com.betfair.tornjak.monitor.DefaultMonitor.java
public void setName(String name) { if (name == null) { throw new IllegalArgumentException("Monitor name can not be null"); }/*w ww.ja v a 2 s .co m*/ this.name = name; timer = new Timer(name, true); logger = LoggerFactory.getLogger(getClass() + "." + name); }
From source file:com.predic8.membrane.core.transport.http.ConnectionManager.java
public ConnectionManager(long keepAliveTimeout) { this.keepAliveTimeout = keepAliveTimeout; this.autoCloseInterval = keepAliveTimeout * 2; timer = new Timer("Connection Closer", true); timer.schedule(new TimerTask() { @Override//from w ww .ja v a 2 s . c o m public void run() { if (closeOldConnections() == 0 && shutdownWhenDone) timer.cancel(); } }, autoCloseInterval, autoCloseInterval); }
From source file:dk.netarkivet.monitor.distribute.JMSMonitorRegistryClient.java
/** Register this host for monitoring. * Once this method is called it will reregister for monitoring every * minute, to ensure the scheduling is done. * If called again, it will restart the timer that registers the host. * @param localHostName The name of the host. * @param jmxPort The port for JMX connections to the host. * @param rmiPort The port for RMI connections for JMX communication. * @throws ArgumentNotValid on null or empty hostname, or negative port * numbers.//from ww w . j a v a 2 s .c om */ public synchronized void register(final String localHostName, final int jmxPort, final int rmiPort) { ArgumentNotValid.checkNotNullOrEmpty(localHostName, "String localHostName"); ArgumentNotValid.checkNotNegative(jmxPort, "int jmxPort"); ArgumentNotValid.checkNotNegative(rmiPort, "int rmiPort"); if (registryTimer != null) { registryTimer.cancel(); } registryTimer = new Timer("Monitor-registry-client", true); TimerTask timerTask = new TimerTask() { /** The action to be performed by this timer task. */ public void run() { JMSConnectionFactory.getInstance().send(new RegisterHostMessage(localHostName, jmxPort, rmiPort)); log.trace("Registering this client for monitoring," + " using hostname '" + localHostName + "' and JMX/RMI ports " + jmxPort + "/" + rmiPort); } }; long reregisterDelay = Settings.getLong(MonitorSettings.DEFAULT_REREGISTER_DELAY); try { reregisterDelay = Long.parseLong(Settings.get(CommonSettings.MONITOR_REGISTRY_CLIENT_REREGISTERDELAY)); } catch (NumberFormatException e1) { log.warn("Couldn't parse setting " + CommonSettings.MONITOR_REGISTRY_CLIENT_REREGISTERDELAY + ". Only numbers are allowed. Using defaultvalue " + MonitorSettings.DEFAULT_REREGISTER_DELAY); } catch (NetarkivetException e2) { log.warn("Couldn't find setting " + CommonSettings.MONITOR_REGISTRY_CLIENT_REREGISTERDELAY + ". Using defaultvalue " + MonitorSettings.DEFAULT_REREGISTER_DELAY); } log.info("Registering this client for monitoring every " + reregisterDelay + " minutes, using hostname '" + localHostName + "' and JMX/RMI ports " + jmxPort + "/" + rmiPort); registryTimer.scheduleAtFixedRate(timerTask, NOW, reregisterDelay * MINUTE_IN_MILLISECONDS); }
From source file:io.github.gsteckman.rpi_rest.SsdpHandler.java
/** * Constructs a new instance of this class. */// ww w. ja v a 2 s .c o m private SsdpHandler() { LOG.info("Instantiating SsdpHandler"); try { // Use first IPv4 address that isn't loopback, any, or link local as the server address Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements() && serverAddress == null) { NetworkInterface i = interfaces.nextElement(); Enumeration<InetAddress> addresses = i.getInetAddresses(); while (addresses.hasMoreElements() && serverAddress == null) { InetAddress address = addresses.nextElement(); if (address instanceof Inet4Address) { if (!address.isAnyLocalAddress() && !address.isLinkLocalAddress() && !address.isLoopbackAddress() && !address.isMulticastAddress()) { serverAddress = address; } } } } if (serverAddress == null) { LOG.warn("Server address unknown"); } svc = SsdpService.forAllMulticastAvailableNetworkInterfaces(this); svc.listen(); // setup Multicast for Notify messages notifySocket = new MulticastSocket(); notifySocket.setTimeToLive(TTL); notifyTimer = new Timer("UPnP Notify Timer", true); notifyTimer.scheduleAtFixedRate(new NotifySender(), 5000, MAX_AGE * 1000 / 2); } catch (Exception e) { LOG.error("SsdpHandler in unknown state due to exception in constructor.", e); } }
From source file:com.googlecode.ehcache.annotations.impl.ExpiredElementEvictor.java
public void afterPropertiesSet() throws Exception { if (null == this.cacheManager) { throw new IllegalStateException("cacheManager reference must be set"); }/* w w w . ja v a2 s . c o m*/ timer = new Timer(this.cacheManager.getName() + "expiredElementEvictorTimer", true); timer.schedule(this, interval, interval); }
From source file:com.icesoft.applications.faces.auctionMonitor.beans.LogBean.java
/** * Method to silently reset the auction every night at midnight *///from w w w . ja v a 2s.com private void timedReset() { // Generate the date for tomorrow at midnight Calendar tomorrow = new GregorianCalendar(); tomorrow.add(Calendar.DATE, 1); Date midnight = new GregorianCalendar(tomorrow.get(Calendar.YEAR), tomorrow.get(Calendar.MONTH), tomorrow.get(Calendar.DATE)).getTime(); // Setup the timer task object, or cancel existing tasks on the current object if (nightlyReset == null) { nightlyReset = new Timer("Nightly Auction Reset", true); } else { nightlyReset.cancel(); nightlyReset.purge(); } // Schedule a task to reset at midnight, then every 24 hours past that nightlyReset.scheduleAtFixedRate(new TimerTask() { public void run() { log.info("Nightly reset of auction items."); resetAuction(true); } }, midnight, TIME_DAYS); }