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:MdDetect.java
/** * Set up a ThreadPoolExecutor to process files in parallel * * @param capacity pool size/* w ww.ja va 2s. c o m*/ */ private static void initExecutor(int capacity) { executorService = new ThreadPoolExecutor(1, // min pool size Runtime.getRuntime().availableProcessors() * 4, // max pool shouldn't exceed cores 2, // how many * how long? TimeUnit.SECONDS, // unit of time new ArrayBlockingQueue<Runnable>(capacity // initialize the list with a finite capacity )); }
From source file:com.xyxy.platform.examples.showcase.demos.schedule.SpringCronJob.java
@PreDestroy public void stop() { ScheduledExecutorService scheduledExecutorService = threadPoolTaskScheduler.getScheduledExecutor(); Threads.normalShutdown(scheduledExecutorService, shutdownTimeout, TimeUnit.SECONDS); }
From source file:org.zenoss.zep.dao.impl.ElapsedTime.java
public static String formatElapsed(final long elapsedMillis) { final long hr = TimeUnit.MILLISECONDS.toHours(elapsedMillis); final long min = TimeUnit.MILLISECONDS.toMinutes(elapsedMillis - TimeUnit.HOURS.toMillis(hr)); final long sec = TimeUnit.MILLISECONDS .toSeconds(elapsedMillis - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min)); final long ms = TimeUnit.MILLISECONDS.toMillis(elapsedMillis - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min) - TimeUnit.SECONDS.toMillis(sec)); return String.format("%02dh:%02dm:%02d.%03ds", hr, min, sec, ms); }
From source file:ru.prbb.activeagent.services.AbstractChecker.java
public void start() { if (ft == null) { ft = exec.scheduleWithFixedDelay(this, 0, getDelaySec(), TimeUnit.SECONDS); } }
From source file:com.ppcxy.cyfm.showcase.demos.schedule.SpringCronJob.java
@PreDestroy public void stop() { ScheduledExecutorService scheduledExecutorService = threadPoolTaskScheduler.getScheduledExecutor(); Threads.gracefulShutdown(scheduledExecutorService, shutdownTimeout, TimeUnit.SECONDS); }
From source file:com.buffalokiwi.api.IdleConnectionMonitorThread.java
/** * Run.//w w w .j a va 2s. c om * Monitors the connection manager and closes idle and expired connections every * 5 seconds. * The idle connection closer will wait at maximum for 30 seconds. */ @Override public void run() { try { while (!shutdown) { synchronized (this) { wait(5000L); // Close expired connections connMgr.closeExpiredConnections(); // Optionally, close connections // that have been idle longer than 30 sec connMgr.closeIdleConnections(30, TimeUnit.SECONDS); } } } catch (InterruptedException ex) { // terminate } }
From source file:org.wso2.carbon.esb.security.policy.ESBJAVA3899_PolicyReferenceInWSDLBindingsTestCase.java
@BeforeClass protected void init() throws Exception { super.init(); uploadResourcesToConfigRegistry();// w ww. j a va 2 s. c o m uploadCapp(carFileName, new DataHandler(new URL("file:" + File.separator + File.separator + getESBResourceLocation() + File.separator + "car" + File.separator + carFileName))); TimeUnit.SECONDS.sleep(5); log.info(carFileName + " uploaded successfully"); }
From source file:org.zalando.spring.boot.example.ExampleApplicationAllDisabledTest.java
@Test public void startUp() throws InterruptedException { if (executor != null) { System.out.println(executor.getClass().getName()); }/*from ww w . ja v a 2s . c om*/ TimeUnit.SECONDS.sleep(3); job.run(); TimeUnit.SECONDS.sleep(2); job.run(); TimeUnit.SECONDS.sleep(2); }
From source file:com.pentaho.ctools.utils.HttpUtils.java
/** * This method shall look for HttpErrors return the status of HTTP request. Will return false if no error with that number was found. * * @param driver//from w w w . j a v a2 s.co m * @param ErrorNumber * @return * @throws Exception */ public static boolean GetHttpError(WebDriver driver, String ErrorNumber) { Boolean errorFound = false; driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); for (int i = 0; i < 1000; i++) { try { driver.findElement(By.id("web_" + ErrorNumber)); errorFound = true; } catch (NoSuchElementException s) { LOG.error("NoSuchElement - got it."); break; } catch (StaleElementReferenceException s) { LOG.error("Stale - got it."); } } driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); return errorFound; }