List of usage examples for java.util Timer Timer
public Timer()
From source file:org.duracloud.snapshot.service.impl.SnapshotFinalizerImpl.java
@Override public void initialize(Integer pollingPeriodMs) { if (timer == null) { timer = new Timer(); TimerTask task = new TimerTask() { /* (non-Javadoc) * @see java.util.TimerTask#run() *//* w w w .j a v a 2 s. c om*/ @Override public void run() { try { log.info("launching periodic snapshot finalization..."); snapshotManager.finalizeSnapshots(); } catch (Exception ex) { ex.printStackTrace(); } } }; if (pollingPeriodMs == null || pollingPeriodMs < 1) { pollingPeriodMs = DEFAULT_POLLING_PERIOD_MS; } timer.schedule(task, new Date(), pollingPeriodMs); log.info("snapshot finalization scheduled to run every " + pollingPeriodMs + " milliseconds."); } }
From source file:com.cnaude.purpleirc.Utilities.UpdateChecker.java
/** * * @param plugin/* w w w .ja v a2s. c o m*/ */ public UpdateChecker(PurpleIRC plugin) { this.timer = new Timer(); this.plugin = plugin; this.currentVersion = plugin.getDescription().getVersion(); try { currentBuild = Integer.valueOf(currentVersion.split("-")[2]); } catch (Exception e) { currentBuild = 0; } startUpdateChecker(); }
From source file:com.twosigma.beakerx.kernel.magic.command.functionality.MvnLoggerWidget.java
public MvnLoggerWidget(Message parentMessage) { this.widget = new BxHTML(parentMessage); this.timer = new Timer(); this.timer.scheduleAtFixedRate(new TimerTask() { @Override//from ww w . j av a 2 s . com public void run() { if (jarNumbers > 0) { String info = getInfo(currentLine); String sizeWithUnit = byteCountToDisplaySize(new Double(sizeInKb * 1000).longValue()); String status = String.format("%d jar%s, %s downloaded at %s %s", jarNumbers, getPluralFormWhenNumberOfJarGreaterThanOne(), sizeWithUnit, speed, info); widget.setValue(status + "</br>" + formatCurrentLine()); widget.setDomClasses(asList("text-ellipsis")); } } }, 0, PERIOD); }
From source file:$servicePackage$.$serviceImpl$ClientInvoker.java
public void afterPropertiesSet() throws Exception { Assert.notNull($serviceImplInstance$); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override/*ww w . jav a2 s . c o m*/ public void run() { try { performRequest(); } catch (Exception ex) { throw new RuntimeException(ex); } } }, delayBeforeSending); }
From source file:edu.unc.lib.dl.cdr.services.FixityLogService.java
public void init() { initializeExecutor(); pollingTimer = new Timer(); pollingTimer.schedule(new ExecuteTask(), 0, pollingIntervalSeconds * 1000); }
From source file:co.mafiagame.engine.util.PurgeTimer.java
@PostConstruct public void initPurgeTimer() { Calendar now = Calendar.getInstance(); now.add(Calendar.SECOND, 10); now.add(Calendar.DATE, 1);//from w w w . j a v a2s .com now.set(Calendar.HOUR_OF_DAY, 6); Timer timer = new Timer(); timer.schedule(this, now.getTime(), 24 * 60 * 60 * 1000); }
From source file:net.sf.jabref.exporter.AutoSaveManager.java
public void startAutoSaveTimer() { if (t != null) { // shut down any previously set timer to not leak any timers t.cancel();/*from w w w. ja va 2s . co m*/ } TimerTask task = new AutoSaveTask(); t = new Timer(); long interval = (long) 60000 * Globals.prefs.getInt(JabRefPreferences.AUTO_SAVE_INTERVAL); t.scheduleAtFixedRate(task, interval, interval); }
From source file:com.nokia.example.capturetheflag.network.SocketIONetworkClient.java
public SocketIONetworkClient() { mHandler = new Handler(); mTimer = new Timer(); }
From source file:jp.primecloud.auto.process.ProcessTimer.java
@Override public void afterPropertiesSet() throws Exception { TimerTask timerTask = new TimerTask() { @Override/*from ww w. j a v a2 s. c o m*/ public void run() { try { processManager.process(); } catch (Throwable e) { log.error(e.getMessage(), e); } } }; timer = new Timer(); timer.schedule(timerTask, 0, 15 * 1000); }
From source file:com.entertailion.android.overlaynews.Downloader.java
public Downloader(Context context) { this.context = context; try {//ww w .j a v a 2 s. c o m timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (System.currentTimeMillis() - updateTime > TIMER_REPEAT) { getFeeds(); } } }, 0, TIMER_REPEAT); } catch (Exception e) { Log.e(LOG_TAG, "Downloader timer", e); } }