List of usage examples for java.util Timer Timer
public Timer(String name)
From source file:com.moss.veracity.core.filemonitor.FileMonitor.java
private FileMonitor(File file, long interval) { this.file = file.getAbsoluteFile(); reset();// w w w. ja v a 2 s . c om timer = new Timer(true); timer.scheduleAtFixedRate(new MonitorTask(), 0, interval); }
From source file:org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilterTests.java
public void testShutsDownTimerThread() throws Exception { final MethodFlag cancelMethodFlag = new MethodFlag(); final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter(); final Timer timer = new Timer(true) { public void cancel() { cancelMethodFlag.setCalled(); super.cancel(); }//from w w w .j a v a 2 s . c om }; filter.setProxyGrantingTicketStorage(storage); filter.setMillisBetweenCleanUps(1); filter.setTimer(timer); filter.setTimerTask(defaultTimerTask); filter.init(); filter.destroy(); assertTrue(cancelMethodFlag.wasCalled()); }
From source file:net.hgw4.testapp.HGWTest.java
public HGWTest() { PropertyConfigurator.configure(System.getProperty("user.dir") + System.getProperty("file.separator") + "configs" + System.getProperty("file.separator") + "log4j.properties"); testAleLogger = Logger.getLogger(HGWTest.class.getName()); testAleLogger.info("--> TestAle <--"); curHal = new Hal(); //createTempKitchenSensor(); //createTempBedroomSensor(); //create and start sych eventhandler sending refernce to observable class curHal.startInternalEventHandler();/* www.j a v a 2s .c om*/ //configure this class to receive events setExternalEventHandler(); //test sensori curHal.startAllDataCollecting(); timer0 = new Timer("poll data from temp sensor"); task0 = new Timer_getDataFromSerial(); timer0.schedule(task0, 1000, 1000); // timer0 = new Timer("poll data from fake sensors"); // task0 = new Timer_getDataFromFakeSensors(); // timer0.schedule(task0,1000,1000); //test attuatore //curHal.startAllDataCommander(); //test cicle barionet relay_1 // timer0 = new Timer("test barionet relay_1"); // task0 = new Timer_setDataForActuators(); // timer0.schedule(task0,1000,1000); /* try { //test log zigbee //out = new BufferedWriter(new FileWriter("...path.../zigbeedata.txt", true)) out = new BufferedWriter(new FileWriter(new File("...path.../zigbeedata.txt")));; } catch (IOException ex) { java.util.logging.Logger.getLogger(TestAle.class.getName()).log(Level.SEVERE, null, ex); } timer4 = new Timer("poll data from znet"); task4 = new Timer_getDataFromZigbee(); timer4.schedule(task4,5000,5000); */ }
From source file:com.github.matthesrieke.simplebroker.SimpleBrokerServlet.java
private void startWatchThread() { this.timerDaemon = new Timer(true); this.timerDaemon.scheduleAtFixedRate(new CheckFile(PRODUCERS_FILE, new Callback() { @Override/*from w ww . jav a2 s.co m*/ public void updateStringSet(Set<String> newSet) { synchronized (SimpleBrokerServlet.this) { SimpleBrokerServlet.this.allowedProducers = newSet; } } @Override public Object getMutex() { return SimpleBrokerServlet.this; } @Override public Set<String> getCurrentStringSet() { return SimpleBrokerServlet.this.allowedProducers; } }), 0L, 60000L); }
From source file:org.geoserver.wps.gs.GeorectifyConfiguration.java
public GeorectifyConfiguration() { GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class); configFile = loader.get(GDAL_CONFIG_FILE); //configFile = new File(GeoserverDataDirectory.getGeoserverDataDirectory(), GDAL_CONFIG_FILE); timer = new Timer(true); timer.schedule(new ConfigurationPoller(), 1000); }
From source file:net.oneandone.stool.overview.config.OverviewConfiguration.java
@Bean public Timer autoRefresh() throws IOException { Timer timer;/*www.ja va2s. co m*/ timer = new Timer("Refresh"); timer.schedule(new PrepareRefresh(session()), 20000, 60000); return timer; }
From source file:bachelorthesis.captchapreviewer.domain.ObservableCaptchaBuilder.java
/** * * The constructor for this class// ww w .j av a2 s . c o m * * @param width the width of the captcha image * @param height the height of the captcha image * @param buildSequence */ public ObservableCaptchaBuilder(int width, int height, String buildSequence) { timer = new Timer("updateTimer"); observers = new ArrayList<>(); try { builder = new CaptchaBuilder(width, height, buildSequence); message = "Build String parsed successfully"; valid = true; } catch (ParseException ex) { Logger.getLogger(ObservableCaptchaBuilder.class.getName()).log(Level.SEVERE, null, ex); message = "Build String parsing failed: " + ex.getMessage(); valid = false; } finally { setStatusChanged(); } }
From source file:edu.uci.ics.hyracks.yarn.am.HyracksYarnApplicationMaster.java
private HyracksYarnApplicationMaster(Options options) { this.options = options; timer = new Timer(true); asks = new ArrayList<ResourceRequest>(); resource2AskMap = new HashMap<Resource, Set<AskRecord>>(); proc2AskMap = new HashMap<AbstractProcess, AskRecord>(); lastResponseId = new AtomicInteger(); String containerIdStr = System.getenv(ApplicationConstants.AM_CONTAINER_ID_ENV); ContainerId containerId = ConverterUtils.toContainerId(containerIdStr); appAttemptId = containerId.getApplicationAttemptId(); }
From source file:ch.rasc.wampspring.demo.various.snake.SnakeService.java
public void startTimer() { this.gameTimer = new Timer(SnakeService.class.getSimpleName() + " Timer"); this.gameTimer.scheduleAtFixedRate(new TimerTask() { @Override/*from w w w . j a va 2 s . c o m*/ public void run() { tick(); } }, 100, 100); }
From source file:com.googlecode.arit.jmx.LeakDetector.java
public void afterPropertiesSet() throws Exception { timer = AccessController.doPrivileged(new PrivilegedAction<Timer>() { public Timer run() { timer = new Timer("LeakDetectorTimer"); timer.schedule(new TimerTask() { @Override// w w w . j ava2 s. co m public void run() { try { runDetection(); } catch (Throwable ex) { log.error("Leak detection failed", ex); } } }, 0, 60000); return timer; } }); }