List of usage examples for java.util.concurrent ThreadPoolExecutor ThreadPoolExecutor
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
From source file:com.espertech.esperio.db.core.ExecutorServices.java
public ExecutorServices(EPServiceProviderSPI spi, Map<String, Executor> workQueue) { this.services = new HashMap<String, ExecutorService>(); for (Map.Entry<String, Executor> entry : workQueue.entrySet()) { Executor queue = entry.getValue(); if (queue.getNumThreads() <= 0) { continue; }/*from ww w . ja v a 2s . com*/ LinkedBlockingQueue<Runnable> runnableQueue = new LinkedBlockingQueue<Runnable>(); ExecutorService service = new ThreadPoolExecutor(queue.getNumThreads(), queue.getNumThreads(), 1000, TimeUnit.SECONDS, runnableQueue); services.put(entry.getKey(), service); } try { spi.getContext().bind("EsperIODBAdapter/ExecutorServices", this); } catch (NamingException e) { log.error("Error binding executor service: " + e.getMessage(), e); } }
From source file:com.vsct.dt.hesperides.events.EventsAggregate.java
/** * The constructor of the aggregator//from w w w.j ava2 s . com * @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.sm.transport.netty.ServerSyncHandler.java
private void init() { BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(maxQueue); threadPools = new ThreadPoolExecutor(maxThreads, maxThreads, 30, TimeUnit.SECONDS, queue); }
From source file:org.seedstack.mqtt.internal.MqttPoolDefinition.java
public MqttPoolDefinition(Configuration configuration) { this.available = configuration.getBoolean(POOL_ENABLED, Boolean.TRUE); if (this.available) { int coreSize = configuration.getInt(POOL_CORE_SIZE, DEFAULT_CORE_SIZE); int maxSize = configuration.getInt(POOL_MAX_SIZE, DEFAULT_MAX_SIZE); int queueSize = configuration.getInt(POOL_QUEUE_SIZE, DEFAULT_QUEUE_SIZE); int keepAlive = configuration.getInt(POOL_KEEP_ALIVE, DEFAULT_KEEP_ALIVE); this.threadPoolExecutor = new ThreadPoolExecutor(coreSize, maxSize, keepAlive, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize)); }//from www . j a va 2s . co m }
From source file:com.manning.androidhacks.hack040.util.LIFOThreadPoolProcessor.java
public LIFOThreadPoolProcessor(int threadCount) { executor = new ThreadPoolExecutor(threadCount, threadCount, 0, TimeUnit.SECONDS, opsToRun); }
From source file:CreateTest.java
static void doTestPool(int nThreads) { done = false;/* w w w .j a v a2s . c o m*/ nCalls = new AtomicInteger(0); ThreadPoolExecutor tpe = new ThreadPoolExecutor(nThreads, nThreads, 50000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); Runnable r = new CreateTest(); for (int i = 0; i < target; i++) { tpe.execute(r); } tpe.shutdown(); try { tpe.awaitTermination(10000000L, TimeUnit.SECONDS); } catch (Exception e) { } }
From source file:tools.datasync.db2db.sync.SyncManagerImpl.java
public void initiate() { try {// ww w .jav a2 s . c o m seedOutExecutor = new ThreadPoolExecutor(1, 1, 100, TimeUnit.MILLISECONDS, queues.getSeedOutQueue()); seedInExecutor = new ThreadPoolExecutor(1, 1, 100, TimeUnit.MILLISECONDS, queues.getSeedInQueue()); } catch (Exception ex) { exceptionHandler.handle(ex, Level.SEVERE, "Initialization Failure"); } }
From source file:hsa.awp.common.mail.MailStressTest.java
@Before public void setUp() { service = new ThreadPoolExecutor(50, 50, 10, TimeUnit.SECONDS, queue); }
From source file:org.lilyproject.repository.bulk.serial.ThreadedRecordWriter.java
public ThreadedRecordWriter(String lilyZk, int numThreads, String repositoryName, String tableName, boolean bulkMode) { this.lilyZk = lilyZk; this.repositoryName = repositoryName; this.tableName = tableName; this.bulkMode = bulkMode; executor = new ThreadPoolExecutor(numThreads, numThreads, 10, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); executor.setRejectedExecutionHandler(new WaitPolicy()); threadLocalBulkIngesters = new ThreadLocal<BulkIngester>(); bulkIngesters = Collections.synchronizedList(Lists.<BulkIngester>newArrayList()); }
From source file:org.apache.cxf.systest.jaxrs.JAXRSCxfContinuationsTest.java
private void doTestContinuation(String pathSegment) throws Exception { ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10)); CountDownLatch startSignal = new CountDownLatch(1); CountDownLatch doneSignal = new CountDownLatch(1); executor.execute(new BookWorker("http://localhost:" + PORT + "/bookstore/" + pathSegment + "/1", "1", "CXF in Action1", startSignal, doneSignal)); startSignal.countDown();/* w w w . java 2s . co m*/ doneSignal.await(60, TimeUnit.SECONDS); executor.shutdownNow(); assertEquals("Not all invocations have completed", 0, doneSignal.getCount()); }