List of usage examples for java.util.concurrent TimeUnit SECONDS
TimeUnit SECONDS
To view the source code for java.util.concurrent TimeUnit SECONDS.
Click Source Link
From source file:com.walmart.gatling.commons.MasterTest.java
@BeforeClass public static void setupActorSystem() throws Exception { FileUtils.deleteDirectory(new File("journal")); FileUtils.deleteDirectory(new File("shared-journal")); FileUtils.deleteDirectory(new File("snapshots")); //file.isDirectory() agentConfig = new AgentConfig(); AgentConfig.LogServer log = new AgentConfig.LogServer(); log.setHostName("127.0.0.1"); log.setPort(8080);//from w ww .j a va 2 s .co m agentConfig.setLogServer(log); system = startMaster(); final Props props = Master.props(new FiniteDuration(20, TimeUnit.SECONDS), agentConfig); master = system.actorOf(props, "master"); }
From source file:com.carolinarollergirls.scoreboard.xml.AutoSaveScoreBoard.java
public synchronized void start() { try {/* w w w. ja v a 2 s . c o m*/ FileUtils.forceMkdir(new File(ScoreBoardManager.getDefaultPath(), DIRECTORY_NAME)); } catch (IOException ioE) { ScoreBoardManager.printMessage( "WARNING: Unable to create auto-save directory '" + DIRECTORY_NAME + "' : " + ioE.getMessage()); return; } Runnable r = new Runnable() { public void run() { backupAutoSavedFiles(); ScoreBoardManager.printMessage("Starting auto-save"); running = executor.scheduleWithFixedDelay(AutoSaveScoreBoard.this, 0, SAVE_DELAY, TimeUnit.SECONDS); } }; running = executor.schedule(r, SAVE_DELAY, TimeUnit.SECONDS); }
From source file:com.magnet.plugin.helpers.URLHelper.java
public static InputStream loadUrl(final String url) throws Exception { final InputStream[] inputStreams = new InputStream[] { null }; final Exception[] exception = new Exception[] { null }; Future<?> downloadThreadFuture = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { try { HttpURLConnection connection; if (ApplicationManager.getApplication() != null) { connection = HttpConfigurable.getInstance().openHttpConnection(url); } else { connection = (HttpURLConnection) new URL(url).openConnection(); connection.setReadTimeout(Rest2MobileConstants.CONNECTION_TIMEOUT); connection.setConnectTimeout(Rest2MobileConstants.CONNECTION_TIMEOUT); }/* w w w . j a v a 2 s .c om*/ connection.connect(); inputStreams[0] = connection.getInputStream(); } catch (IOException e) { exception[0] = e; } } }); try { downloadThreadFuture.get(5, TimeUnit.SECONDS); } catch (TimeoutException ignored) { } if (!downloadThreadFuture.isDone()) { downloadThreadFuture.cancel(true); throw new ConnectionException(IdeBundle.message("updates.timeout.error")); } if (exception[0] != null) throw exception[0]; return inputStreams[0]; }
From source file:Main.java
public void start(String[] args) { Runnable showResultsAction = new Runnable() { public void run() { showResults();//from w w w .j a v a 2 s. c om results.clear(); } }; barrier = new CyclicBarrier(args.length, showResultsAction); for (final String site : args) new Thread() { public void run() { while (true) { long time = timeConnect(site); results.add(new Result(time, site)); try { barrier.await(99, TimeUnit.SECONDS); } catch (BrokenBarrierException e) { return; } catch (Exception e) { return; } } } }.start(); }
From source file:Main.java
public void start(String[] args) { Runnable showResultsAction = new Runnable() { public void run() { showResults();//from w w w. ja v a 2s . com results.clear(); } }; barrier = new CyclicBarrier(args.length, showResultsAction); for (final String site : args) new Thread() { public void run() { while (true) { long time = timeConnect(site); results.add(new Result(time, site)); try { barrier.await(99, TimeUnit.SECONDS); barrier.reset(); } catch (BrokenBarrierException e) { return; } catch (Exception e) { return; } } } }.start(); }
From source file:Main.java
public void start(String[] args) { Runnable showResultsAction = new Runnable() { public void run() { showResults();/* w ww. ja v a 2s . co m*/ results.clear(); } }; barrier = new CyclicBarrier(args.length, showResultsAction); for (final String site : args) new Thread() { public void run() { while (true) { long time = timeConnect(site); results.add(new Result(time, site)); try { barrier.await(99, TimeUnit.SECONDS); System.out.println(barrier.isBroken()); } catch (BrokenBarrierException e) { return; } catch (Exception e) { return; } } } }.start(); }
From source file:Main.java
public void start(String[] args) { Runnable showResultsAction = new Runnable() { public void run() { showResults();/* www . j ava 2 s . c o m*/ results.clear(); } }; barrier = new CyclicBarrier(args.length, showResultsAction); for (final String site : args) new Thread() { public void run() { while (true) { long time = timeConnect(site); results.add(new Result(time, site)); try { barrier.await(99, TimeUnit.SECONDS); System.out.println(barrier.getParties()); } catch (BrokenBarrierException e) { return; } catch (Exception e) { return; } } } }.start(); }
From source file:Main.java
public void start(String[] args) { Runnable showResultsAction = new Runnable() { public void run() { showResults();//w ww . ja v a2s . com results.clear(); } }; barrier = new CyclicBarrier(args.length, showResultsAction); for (final String site : args) new Thread() { public void run() { while (true) { long time = timeConnect(site); results.add(new Result(time, site)); try { barrier.await(99, TimeUnit.SECONDS); System.out.println(barrier.getNumberWaiting()); } catch (BrokenBarrierException e) { return; } catch (Exception e) { return; } } } }.start(); }
From source file:io.airlift.stats.TimeStat.java
public TimeStat() { this(Ticker.systemTicker(), TimeUnit.SECONDS); }
From source file:com.muk.services.web.client.IdleConnectionMonitor.java
@Override public void run() { try {//from w w w . j a va 2 s . c om while (!Thread.currentThread().isInterrupted()) { Thread.sleep(5000); connMgr.closeExpiredConnections(); connMgr.closeIdleConnections(30, TimeUnit.SECONDS); } } catch (final InterruptedException ex) { Thread.currentThread().interrupt(); } }