use of java.util.concurrent.SynchronousQueue in project hive by apache.
the class TestJdbcWithMiniHS2 method startConcurrencyTest.
private static void startConcurrencyTest(Connection conn, String tableName, int numTasks) {
// Start concurrent testing
int poolSize = 100;
SynchronousQueue<Runnable> executorQueue = new SynchronousQueue<Runnable>();
ExecutorService workers = new ThreadPoolExecutor(1, poolSize, 20, TimeUnit.SECONDS, executorQueue);
List<Future<Boolean>> list = startTasks(workers, conn, tableName, numTasks);
finishTasks(list, workers);
}
use of java.util.concurrent.SynchronousQueue in project hive by apache.
the class TestJdbcWithMiniHS2 method testParallelCompilation4.
@Test
public void testParallelCompilation4() throws Exception {
Statement stmt = conTestDb.createStatement();
stmt.execute("set hive.driver.parallel.compilation=true");
stmt.execute("set hive.server2.async.exec.async.compile=false");
stmt.close();
Connection conn = getConnection(testDbName);
stmt = conn.createStatement();
stmt.execute("set hive.driver.parallel.compilation=true");
stmt.execute("set hive.server2.async.exec.async.compile=false");
stmt.close();
int poolSize = 100;
SynchronousQueue<Runnable> executorQueue1 = new SynchronousQueue<Runnable>();
ExecutorService workers1 = new ThreadPoolExecutor(1, poolSize, 20, TimeUnit.SECONDS, executorQueue1);
SynchronousQueue<Runnable> executorQueue2 = new SynchronousQueue<Runnable>();
ExecutorService workers2 = new ThreadPoolExecutor(1, poolSize, 20, TimeUnit.SECONDS, executorQueue2);
List<Future<Boolean>> list1 = startTasks(workers1, conTestDb, tableName, 10);
List<Future<Boolean>> list2 = startTasks(workers2, conn, tableName, 10);
finishTasks(list1, workers1);
finishTasks(list2, workers2);
conn.close();
}
use of java.util.concurrent.SynchronousQueue in project zookeeper by apache.
the class QuorumCnxManager method initializeConnectionExecutor.
// we always use the Connection Executor during connection initiation (to handle connection
// timeouts), and optionally use it during receiving connections (as the Quorum SASL authentication
// can take extra time)
private void initializeConnectionExecutor(final long mySid, final int quorumCnxnThreadsSize) {
final AtomicInteger threadIndex = new AtomicInteger(1);
SecurityManager s = System.getSecurityManager();
final ThreadGroup group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
final ThreadFactory daemonThFactory = runnable -> new Thread(group, runnable, String.format("QuorumConnectionThread-[myid=%d]-%d", mySid, threadIndex.getAndIncrement()));
this.connectionExecutor = new ThreadPoolExecutor(3, quorumCnxnThreadsSize, 60, TimeUnit.SECONDS, new SynchronousQueue<>(), daemonThFactory);
this.connectionExecutor.allowCoreThreadTimeOut(true);
}
use of java.util.concurrent.SynchronousQueue in project dubbo by alibaba.
the class FixedThreadPool method getExecutor.
@Override
public Executor getExecutor(URL url) {
String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
int threads = url.getParameter(THREADS_KEY, DEFAULT_THREADS);
int queues = url.getParameter(QUEUES_KEY, DEFAULT_QUEUES);
return new ThreadPoolExecutor(threads, threads, 0, TimeUnit.MILLISECONDS, queues == 0 ? new SynchronousQueue<Runnable>() : (queues < 0 ? new LinkedBlockingQueue<Runnable>() : new LinkedBlockingQueue<Runnable>(queues)), new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url));
}
use of java.util.concurrent.SynchronousQueue in project jmeter by apache.
the class ResourcesDownloader method init.
private void init() {
LOG.info("Creating ResourcesDownloader with keepalive_inseconds : {}", THREAD_KEEP_ALIVE_TIME);
concurrentExecutor = new ThreadPoolExecutor(MIN_POOL_SIZE, MAX_POOL_SIZE, THREAD_KEEP_ALIVE_TIME, TimeUnit.SECONDS, new SynchronousQueue<>(), r -> {
Thread t = new Thread(r);
// $NON-NLS-1$
t.setName("ResDownload-" + t.getName());
t.setDaemon(true);
return t;
}) {
};
}
Aggregations