List of usage examples for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue
public LinkedBlockingQueue(Collection<? extends E> c)
From source file:com.kurento.kmf.content.internal.ContentApiExecutorService.java
/** * Post constructor method; instantiate thread pool. * //from w ww . j ava 2s. c o m * @throws Exception * Error in the creation of the thread pool */ @PostConstruct public void afterPropertiesSet() throws Exception { executor = new ThreadPoolExecutor(config.getPoolCoreSize(), config.getPoolMaxSize(), config.getPoolExecutionTimeout(), TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(config.getPoolMaxQueueSize()), new RejectedExecutionHandler() { @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { ((RejectableRunnable) r).onExecutionRejected(); } }); }
From source file:edu.umn.msi.tropix.jobs.activities.factories.PollJobActivityFactoryImpl.java
private static <T> Function<String, LinkedBlockingQueue<T>> getQueueFunction(final int max) { return new Function<String, LinkedBlockingQueue<T>>() { public LinkedBlockingQueue<T> apply(final String arg) { return new LinkedBlockingQueue<T>(max); }//from w ww . ja va2s . co m }; }
From source file:com.netflix.suro.sink.notice.QueueNotice.java
public QueueNotice() { queue = new LinkedBlockingQueue<E>(DEFAULT_LENGTH); timeout = DEFAULT_TIMEOUT; Monitors.registerObject(this); }
From source file:fr.aliasource.webmail.pool.Pool.java
public Pool(String poolId, IPoolableObjectFactory<T> factory, int poolSize, String destroyMethodName, long keepAlivePeriod) { this.logger = LogFactory.getLog(getClass()); this.poolId = poolId; this.objectsInUse = Collections.synchronizedSet(new HashSet<T>()); this.destroyMethod = destroyMethodName; this.availableObjects = new LinkedBlockingQueue<T>(poolSize); for (int i = 0; i < poolSize; i++) { logger.info(poolId + ": Adding pooled object..."); availableObjects.add(factory.createNewObject()); logger.info(poolId + ": Pooled object added."); }// w w w. j av a 2s. c o m keepAliveTimer = new Timer(poolId + "-keepalive-timer", true); KeepAliveTask<T> kaTsk = new KeepAliveTask<T>(availableObjects, factory, this); keepAliveTimer.scheduleAtFixedRate(kaTsk, 10000, keepAlivePeriod); }
From source file:com.vsct.dt.hesperides.events.EventsAggregate.java
/** * The constructor of the aggregator//from w w w . j av a 2s .co m * @param eventStore */ public EventsAggregate(final EventsConfiguration eventsConfiguration, final EventStore eventStore) { this.eventStore = eventStore; this.executor = new ThreadPoolExecutor(eventsConfiguration.getPoolMinSize(), eventsConfiguration.getPoolMaxSize(), 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(eventsConfiguration.getQueueCapacity())); }
From source file:com.graphhopper.reader.OSMInputFile.java
public OSMInputFile(File file) throws IOException { bis = decode(file); itemQueue = new LinkedBlockingQueue<OSMElement>(50000); }
From source file:com.graphhopper.reader.osm.OSMInputFile.java
public OSMInputFile(File file) throws IOException { bis = decode(file); itemQueue = new LinkedBlockingQueue<ReaderElement>(50000); }
From source file:com.sm.store.server.StoreServerHandler.java
private void init() { if (Runtime.getRuntime().availableProcessors() > maxThreads) this.maxThreads = Runtime.getRuntime().availableProcessors(); if (maxQueue < maxThreads * 1000) maxQueue = maxThreads * 1000;//from ww w .j a v a 2s. com BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(maxQueue); threadPools = new ThreadPoolExecutor(maxThreads, maxThreads, 30, TimeUnit.SECONDS, queue, new ThreadPoolFactory("store")); }
From source file:com.kurento.kmf.thrift.internal.ThriftInterfaceExecutorService.java
/** * Post constructor method; instantiate thread pool. * /*from w w w .ja v a2s . c om*/ * @throws Exception * Error in the creation of the thread pool */ @PostConstruct public void afterPropertiesSet() throws Exception { executor = new ThreadPoolExecutor(config.getPoolCoreSize(), config.getPoolMaxSize(), config.getPoolExecutionTimeout(), TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(config.getPoolMaxQueueSize()), new RejectedExecutionHandler() { @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor exec) { log.warn("Execution is blocked because the thread bounds and queue capacities are reached"); } }); }
From source file:com.addthis.codec.utils.ExecutorServiceBuilder.java
@JsonCreator public ExecutorServiceBuilder(@JsonProperty("thread-factory") ThreadFactory threadFactory, @JsonProperty("core-threads") int coreThreads, @JsonProperty("max-threads") int maxThreads, @JsonProperty("keep-alive") @Time(TimeUnit.MILLISECONDS) int keepAlive, @JsonProperty("queue-size") int queueSize, @JsonProperty("queue-gauge-class") Class<?> gaugeClass, @JsonProperty("queue-gauge-name") String gaugeName, @JsonProperty("shutdown-hook") boolean shutdownHook) { this.threadFactory = threadFactory; this.coreThreads = coreThreads; this.maxThreads = maxThreads; this.keepAlive = keepAlive; this.queue = new LinkedBlockingQueue<>(queueSize); if ((gaugeClass != null) && (gaugeName != null)) { Metrics.newGauge(gaugeClass, gaugeName, new SizeGauge(queue)); }/* w ww. jav a 2 s . com*/ this.shutdownHook = shutdownHook; }