List of usage examples for java.util.concurrent ThreadPoolExecutor getKeepAliveTime
public long getKeepAliveTime(TimeUnit unit)
From source file:Main.java
/** * /* w ww . j av a 2 s . c om*/ */ protected static void decorateProperties(ThreadPoolExecutor executor, Properties properties) { if (executor != null) { if (properties != null) { properties.setProperty("thread-keep-alive-time", Long.toString(executor.getKeepAliveTime(TimeUnit.MILLISECONDS))); properties.setProperty("thread-pool-size-largest", Integer.toString(executor.getLargestPoolSize())); properties.setProperty("thread-pool-size-minimum", Integer.toString(executor.getCorePoolSize())); properties.setProperty("thread-pool-size-maximum", Integer.toString(executor.getMaximumPoolSize())); properties.setProperty("thread-pool-size", Integer.toString(executor.getPoolSize())); properties.setProperty("runnable-completed-count", Long.toString(executor.getCompletedTaskCount())); properties.setProperty("runnable-active-count", Integer.toString(executor.getActiveCount())); properties.setProperty("queue-size", Integer.toString(executor.getQueue().size())); properties.setProperty("queue-capacity-remaining", Integer.toString(executor.getQueue().remainingCapacity())); } } }
From source file:org.geotools.gce.imagemosaic.ImageMosaicReader.java
/** * Constructor.//from w ww .ja v a 2 s. c o m * * @param source * The source object. * @throws IOException * @throws UnsupportedEncodingException * */ public ImageMosaicReader(Object source, Hints uHints) throws IOException { super(source, uHints); // // try to extract a multithreaded loader if available // if (this.hints.containsKey(Hints.EXECUTOR_SERVICE)) { final Object executor = uHints.get(Hints.EXECUTOR_SERVICE); if (executor != null && executor instanceof ExecutorService) { multiThreadedLoader = (ExecutorService) executor; if (LOGGER.isLoggable(Level.FINE)) { if (multiThreadedLoader instanceof ThreadPoolExecutor) { final ThreadPoolExecutor tpe = (ThreadPoolExecutor) multiThreadedLoader; LOGGER.fine("Using ThreadPoolExecutor with the following settings: " + "core pool size = " + tpe.getCorePoolSize() + "\nmax pool size = " + tpe.getMaximumPoolSize() + "\nkeep alive time " + tpe.getKeepAliveTime(TimeUnit.MILLISECONDS)); } } } } if (this.hints.containsKey(Hints.MAX_ALLOWED_TILES)) this.maxAllowedTiles = ((Integer) this.hints.get(Hints.MAX_ALLOWED_TILES)); // // Check source // if (source instanceof ImageMosaicDescriptor) { initReaderFromDescriptor((ImageMosaicDescriptor) source, uHints); } else { try { initReaderFromURL(source, uHints); } catch (Exception e) { throw new DataSourceException(e); } } }