本文整理了Java中java.util.concurrent.ForkJoinPool.<init>()
方法的一些代码示例,展示了ForkJoinPool.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ForkJoinPool.<init>()
方法的具体详情如下:
包路径:java.util.concurrent.ForkJoinPool
类名称:ForkJoinPool
方法名:<init>
[英]Creates a ForkJoinPool with parallelism equal to java.lang.Runtime#availableProcessors, using the #defaultForkJoinWorkerThreadFactory, no UncaughtExceptionHandler, and non-async LIFO processing mode.
[中]创建并行度等于java的ForkJoinPool。lang.Runtime可用处理器,使用#defaultForkJoinWorkerThreadFactory、无UncaughtExceptionHandler和非异步后进先出处理模式。
代码示例来源:origin: stackoverflow.com
ForkJoinPool forkJoinPool = new ForkJoinPool(2);
forkJoinPool.submit(() ->
//parallel task here, for example
IntStream.range(1, 1_000_000).parallel().filter(PrimesPrint::isPrime).collect(toList())
).get();
代码示例来源:origin: neo4j/neo4j
@Override
public ExecutorService build( Group group, SchedulerThreadFactory factory, int threadCount )
{
return new ForkJoinPool( threadCount, factory, null, false );
}
};
代码示例来源:origin: languagetool-org/languagetool
/**
* @see #shutdown()
* @param threadPoolSize the number of concurrent threads
* @since 2.9
* UserConfig added
* @since 4.2
*/
public MultiThreadedJLanguageTool(Language language, Language motherTongue, int threadPoolSize,
UserConfig userConfig) {
super(language, motherTongue, null, userConfig);
this.threadPoolSize = threadPoolSize;
threadPool = new ForkJoinPool(threadPoolSize, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, false);
}
代码示例来源:origin: deeplearning4j/nd4j
public static synchronized ForkJoinPool getForkJoinPool() {
if (forkJoinPool != null)
return forkJoinPool;
forkJoinPool = new ForkJoinPool(nThreads, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
return forkJoinPool;
}
代码示例来源:origin: stackoverflow.com
ForkJoinPool forkJoinPool = new ForkJoinPool(2);
CompletableFuture<List<Integer>> primes = CompletableFuture.supplyAsync(() ->
//parallel task here, for example
range(1, 1_000_000).parallel().filter(PrimesPrint::isPrime).collect(toList()),
forkJoinPool
);
代码示例来源:origin: spring-projects/spring-framework
@Override
public void afterPropertiesSet() {
this.forkJoinPool = (this.commonPool ? ForkJoinPool.commonPool() :
new ForkJoinPool(this.parallelism, this.threadFactory, this.uncaughtExceptionHandler, this.asyncMode));
}
代码示例来源:origin: neo4j/neo4j
@Override
public ExecutorService build( Group group, SchedulerThreadFactory factory )
{
return new ForkJoinPool( getRuntime().availableProcessors(), factory, null, false );
}
代码示例来源:origin: Atmosphere/atmosphere
public ForkJoinPool(boolean shared, final String threadName) {
this.shared = shared;
forkJoinPool = new java.util.concurrent.ForkJoinPool(Runtime.getRuntime().availableProcessors(), new java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory() {
@Override
public java.util.concurrent.ForkJoinWorkerThread newThread(java.util.concurrent.ForkJoinPool pool) {
return new JDK7ForkJoinWorkerThread(pool, ForkJoinPool.this.shared, threadName);
}
}, null, false);
logger.info("Using ForkJoinPool {}. Set the {} to -1 to fully use its power.", forkJoinPool.getClass().getName(), ApplicationConfig.BROADCASTER_ASYNC_WRITE_THREADPOOL_MAXSIZE);
}
代码示例来源:origin: neo4j/neo4j
private ExecutorService createNewWorkStealingExecutor( Group group, int parallelism, boolean asyncMode )
{
ForkJoinPool.ForkJoinWorkerThreadFactory factory =
new GroupedDaemonThreadFactory( group, topLevelGroup );
return new ForkJoinPool( parallelism, factory, null, asyncMode );
}
代码示例来源:origin: robovm/robovm
/**
* Creates a work-stealing thread pool using all
* {@link Runtime#availableProcessors available processors}
* as its target parallelism level.
* @return the newly created thread pool
* @since 1.8
* @hide
*/
public static ExecutorService newWorkStealingPool() {
return new ForkJoinPool
(Runtime.getRuntime().availableProcessors(),
ForkJoinPool.defaultForkJoinWorkerThreadFactory,
null, true);
}
代码示例来源:origin: org.springframework/spring-context
@Override
public void afterPropertiesSet() {
this.forkJoinPool = (this.commonPool ? ForkJoinPool.commonPool() :
new ForkJoinPool(this.parallelism, this.threadFactory, this.uncaughtExceptionHandler, this.asyncMode));
}
代码示例来源:origin: kilim/kilim
public ForkJoinScheduler(int numThreads) {
numThreads = numThreads >= 0 ? numThreads : Scheduler.defaultNumberThreads;
pool = new ForkJoinPool(numThreads);
timerService = new TimerService(this);
}
代码示例来源:origin: spotbugs/spotbugs
@NoWarning("NP_NONNULL_PARAM_VIOLATION")
public void testNominal() {
new ForkJoinPool(2, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
}
代码示例来源:origin: apache/hbase
DirScanPool(Configuration conf) {
String poolSize = conf.get(CHORE_POOL_SIZE, DEFAULT_CHORE_POOL_SIZE);
size = calculatePoolSize(poolSize);
// poolSize may be 0 or 0.0 from a careless configuration,
// double check to make sure.
size = size == 0 ? calculatePoolSize(DEFAULT_CHORE_POOL_SIZE) : size;
pool = new ForkJoinPool(size);
LOG.info("Cleaner pool size is {}", size);
reconfigNotification = new AtomicBoolean(false);
cleanerLatch = 0;
}
代码示例来源:origin: apache/hbase
/**
* Update pool with new size.
*/
synchronized void updatePool(long timeout) {
long stopTime = System.currentTimeMillis() + timeout;
while (cleanerLatch != 0 && timeout > 0) {
try {
wait(timeout);
timeout = stopTime - System.currentTimeMillis();
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
break;
}
}
shutDownNow();
LOG.info("Update chore's pool size from {} to {}", pool.getParallelism(), size);
pool = new ForkJoinPool(size);
}
代码示例来源:origin: orbit/orbit
public static ExecutorService newScalingThreadPool(final int maxThreads)
{
final ForkJoinPool.ForkJoinWorkerThreadFactory factory = pool ->
{
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
worker.setName("OrbitThread-" + worker.getPoolIndex());
return worker;
};
return new ForkJoinPool(maxThreads, factory, (t, e) -> logger.log(Level.SEVERE, "Uncaught exception", e), false);
}
}
代码示例来源:origin: spotbugs/spotbugs
@ExpectWarning("NP_NONNULL_PARAM_VIOLATION")
public void testWarning() {
new ForkJoinPool(2, null, new Handler(), true);
}
}
代码示例来源:origin: apache/geode
public static ExecutorService newWorkStealingPool(String threadName, int maxParallelThreads) {
final ForkJoinWorkerThreadFactory factory = pool -> {
ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
LoggingUncaughtExceptionHandler.setOnThread(worker);
worker.setName(threadName + worker.getPoolIndex());
return worker;
};
return new ForkJoinPool(maxParallelThreads, factory, null, true);
}
代码示例来源:origin: neo4j/neo4j
@Override
public void start()
{
forkJoinThreadPool = new ForkJoinPool();
config.enabledBoltConnectors().forEach( connector ->
{
BoltScheduler boltScheduler =
new ExecutorBoltScheduler( connector.key(), executorFactory, scheduler, logService, config.get( connector.thread_pool_min_size ),
config.get( connector.thread_pool_max_size ), config.get( connector.thread_pool_keep_alive ),
config.get( connector.unsupported_thread_pool_queue_size ), forkJoinThreadPool );
boltScheduler.start();
boltSchedulers.put( connector.key(), boltScheduler );
} );
}
代码示例来源:origin: oracle/opengrok
/**
* Initializes a new instance using settings from the specified environment
* instance.
* @param env a defined instance
*/
public IndexerParallelizer(RuntimeEnvironment env) {
int indexingParallelism = env.getIndexingParallelism();
// The order of the following is important.
this.fixedExecutor = Executors.newFixedThreadPool(indexingParallelism);
this.forkJoinPool = new ForkJoinPool(indexingParallelism);
this.ctagsPool = new BoundedBlockingObjectPool<>(indexingParallelism,
new CtagsValidator(), new CtagsObjectFactory(env));
}
内容来源于网络,如有侵权,请联系作者删除!