当前位置: 首页>>代码示例>>Java>>正文


Java ThreadPoolExecutor.prestartAllCoreThreads方法代码示例

本文整理汇总了Java中java.util.concurrent.ThreadPoolExecutor.prestartAllCoreThreads方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolExecutor.prestartAllCoreThreads方法的具体用法?Java ThreadPoolExecutor.prestartAllCoreThreads怎么用?Java ThreadPoolExecutor.prestartAllCoreThreads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ThreadPoolExecutor的用法示例。


在下文中一共展示了ThreadPoolExecutor.prestartAllCoreThreads方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
@BeforeExperiment void setUp() throws Exception {
  executorService = new ThreadPoolExecutor(NUM_THREADS,
      NUM_THREADS,
      Long.MAX_VALUE,
      TimeUnit.SECONDS,
      new ArrayBlockingQueue<Runnable>(1000));
  executorService.prestartAllCoreThreads();
  final AtomicInteger integer = new AtomicInteger();
  // Execute a bunch of tasks to ensure that our threads are allocated and hot
  for (int i = 0; i < NUM_THREADS * 10; i++) {
    @SuppressWarnings("unused") // go/futurereturn-lsc
    Future<?> possiblyIgnoredError =
        executorService.submit(
            new Runnable() {
              @Override
              public void run() {
                integer.getAndIncrement();
              }
            });
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:ExecutionListBenchmark.java

示例2: multiThreadUpload

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
private ThreadPoolExecutor multiThreadUpload(int threadNum, final int threadFileNum) {

    ThreadPoolExecutor pool = (ThreadPoolExecutor) Executors.newFixedThreadPool(threadNum);
    pool.prestartAllCoreThreads();

    for (int i = 0; i < threadNum; ++i) {
      final int threadId = i;
      pool.submit(new Runnable() {
        @Override
        public void run() {
          uploadAndDownloadPerform(threadId, threadFileNum);
        }
      });
    }
    pool.shutdown();
    return pool;
  }
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:18,代码来源:FileCachePerf.java

示例3: testPrestartAllCoreThreads

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
/**
 * prestartAllCoreThreads starts all corePoolSize threads
 */
public void testPrestartAllCoreThreads() {
    final ThreadPoolExecutor p =
        new ThreadPoolExecutor(2, 6,
                               LONG_DELAY_MS, MILLISECONDS,
                               new ArrayBlockingQueue<Runnable>(10));
    try (PoolCleaner cleaner = cleaner(p)) {
        assertEquals(0, p.getPoolSize());
        p.prestartAllCoreThreads();
        assertEquals(2, p.getPoolSize());
        p.prestartAllCoreThreads();
        assertEquals(2, p.getPoolSize());
        p.setCorePoolSize(4);
        p.prestartAllCoreThreads();
        assertEquals(4, p.getPoolSize());
        p.prestartAllCoreThreads();
        assertEquals(4, p.getPoolSize());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:ThreadPoolExecutorTest.java

示例4: testPrestartAllCoreThreads

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
/**
 * prestartAllCoreThreads starts all corePoolSize threads
 */
public void testPrestartAllCoreThreads() {
    final ThreadPoolExecutor p =
        new CustomTPE(2, 6,
                      LONG_DELAY_MS, MILLISECONDS,
                      new ArrayBlockingQueue<Runnable>(10));
    try (PoolCleaner cleaner = cleaner(p)) {
        assertEquals(0, p.getPoolSize());
        p.prestartAllCoreThreads();
        assertEquals(2, p.getPoolSize());
        p.prestartAllCoreThreads();
        assertEquals(2, p.getPoolSize());
        p.setCorePoolSize(4);
        p.prestartAllCoreThreads();
        assertEquals(4, p.getPoolSize());
        p.prestartAllCoreThreads();
        assertEquals(4, p.getPoolSize());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:ThreadPoolExecutorSubclassTest.java

示例5: setUp

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
@BeforeExperiment void setUp() throws Exception {
  executorService = new ThreadPoolExecutor(NUM_THREADS,
      NUM_THREADS,
      Long.MAX_VALUE,
      TimeUnit.SECONDS,
      new ArrayBlockingQueue<Runnable>(1000));
  executorService.prestartAllCoreThreads();
  final AtomicInteger integer = new AtomicInteger();
  // Execute a bunch of tasks to ensure that our threads are allocated and hot
  for (int i = 0; i < NUM_THREADS * 10; i++) {
    executorService.submit(new Runnable() {
      @Override public void run() {
        integer.getAndIncrement();
      }
    });
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:18,代码来源:ExecutionListBenchmark.java

示例6: test

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
public void test(int nTasks, int nParallel) {
	
	
	for(int i=0; i<nTasks; i++) {
		System.err.println(i);
		ThreadPoolExecutor pool = (ThreadPoolExecutor) Executors.newFixedThreadPool(nParallel);
		pool.prestartAllCoreThreads();
		for(int k=0; k<nParallel; k++) pool.submit(new Task());
		try { waitComplete(); }
		catch(Exception e) { e.printStackTrace(); }
		pool.shutdown();
	}
	
}
 
开发者ID:attipaci,项目名称:crush,代码行数:15,代码来源:UlimitTest.java

示例7: createExecutorService

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
private ExecutorService createExecutorService(int poolSize, int workQueueMaxSize, boolean
        prestartThreadPool) {

    logger.info("create HConnectionThreadPoolExecutor poolSize:{}, workerQueueMaxSize:{}",
            poolSize, workQueueMaxSize);

    ThreadPoolExecutor threadPoolExecutor = ExecutorFactory.newFixedThreadPool(poolSize,
            workQueueMaxSize, "Pinpoint-HConnectionExecutor", true);
    if (prestartThreadPool) {
        logger.info("prestartAllCoreThreads");
        threadPoolExecutor.prestartAllCoreThreads();
    }

    return threadPoolExecutor;
}
 
开发者ID:fchenxi,项目名称:easyhbase,代码行数:16,代码来源:PooledHTableFactory.java

示例8: AsyncCacheLoader

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
public AsyncCacheLoader(Component component) {
    ThreadPoolExecutor pool = new ThreadPoolExecutor(
            1, 1, Long.MAX_VALUE, TimeUnit.MINUTES, new LinkedBlockingQueue<>()
    );
    pool.allowCoreThreadTimeOut(false);
    pool.prestartAllCoreThreads();
    lex = MoreExecutors.listeningDecorator(pool);
    this.component = component;
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:10,代码来源:ToolTipList.java

示例9: RedisAccessParallel

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
public RedisAccessParallel(Map<Integer, String> redisMap) {
  super(redisMap);
  this.checkResultTimeoutMs = Config.getInstance().getCheckJedisResultTimeoutMs();

  pool = (ThreadPoolExecutor) Executors.newFixedThreadPool(Config.getInstance().getRedisAccessThreadNum());
  pool.prestartAllCoreThreads();
}
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:8,代码来源:RedisAccessParallel.java

示例10: FlexibleThreadPoolWrapper

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
private FlexibleThreadPoolWrapper(int minThreadCount, int maxThreadCount, long keepAlive, TimeUnit timeUnit,
        ThreadFactory threadFactory, BlockingQueue<Runnable> queue) {

    executor = new ThreadPoolExecutor(minThreadCount, maxThreadCount, keepAlive, timeUnit,
            queue, threadFactory, new FlexibleRejectionHandler());
    executor.prestartAllCoreThreads();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:FlexibleThreadPoolWrapper.java

示例11: createExecutor

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
private static ExecutorService createExecutor(
    int workerThreads, ThriftMetrics metrics) {
  CallQueue callQueue = new CallQueue(
      new LinkedBlockingQueue<Call>(), metrics);
  ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();
  tfb.setDaemon(true);
  tfb.setNameFormat("thrift2-worker-%d");
  ThreadPoolExecutor pool = new ThreadPoolExecutor(workerThreads, workerThreads,
          Long.MAX_VALUE, TimeUnit.SECONDS, callQueue, tfb.build());
  pool.prestartAllCoreThreads();
  return pool;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:ThriftServer.java

示例12: init

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
public  void init (){

        RejectedExecutionHandlerImpl rejectionHandler = new RejectedExecutionHandlerImpl();

        ThreadFactory threadFactory = Executors.defaultThreadFactory();

        executorPool = new ThreadPoolExecutor(CORE, MAX, TIMEOUT, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100),
                threadFactory, rejectionHandler);

        monitor = new MyMonitorThread(executorPool, 15);
        Thread monitorThread = new Thread(monitor);
        monitorThread.start();

        executorPool.prestartAllCoreThreads();

    }
 
开发者ID:HttpRequester,项目名称:Requester,代码行数:17,代码来源:ConnectionThreadPool.java


注:本文中的java.util.concurrent.ThreadPoolExecutor.prestartAllCoreThreads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。