コード例 #1
0
 @Override
 public SubmitterScheduler makeSubmitterScheduler(int poolSize, boolean prestartIfAvailable) {
   ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(poolSize);
   if (prestartIfAvailable) {
     executor.prestartAllCoreThreads();
   }
   executors.add(executor);
   return new ScheduledExecutorServiceWrapper(executor);
 }
コード例 #2
0
ファイル: SimpleTimer2.java プロジェクト: alexwykoff/i2p
 /**
  * To be instantiated by the context. Others should use context.simpleTimer2() instead
  *
  * @since 0.9
  */
 protected SimpleTimer2(I2PAppContext context, String name, boolean prestartAllThreads) {
   _name = name;
   long maxMemory = Runtime.getRuntime().maxMemory();
   if (maxMemory == Long.MAX_VALUE) maxMemory = 96 * 1024 * 1024l;
   _threads =
       (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32 * 1024 * 1024))));
   _executor = new CustomScheduledThreadPoolExecutor(_threads, new CustomThreadFactory());
   if (prestartAllThreads) _executor.prestartAllCoreThreads();
   // don't bother saving ref to remove hook if somebody else calls stop
   context.addShutdownTask(new Shutdown());
 }
コード例 #3
0
ファイル: ExecutionPool.java プロジェクト: RainerJava/etk-erp
 public static ScheduledExecutorService getExecutor(
     ThreadGroup group, String namePrefix, int threadCount, boolean preStart) {
   if (threadCount == 0) {
     threadCount = 1;
   } else if (threadCount < 0) {
     int numCpus = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
     threadCount = Math.abs(threadCount) * numCpus;
   }
   ThreadFactory threadFactory = createThreadFactory(group, namePrefix);
   ScheduledThreadPoolExecutor executor =
       new ScheduledThreadPoolExecutor(threadCount, threadFactory);
   if (preStart) {
     executor.prestartAllCoreThreads();
   }
   return executor;
 }
コード例 #4
0
ファイル: ExecutorService.java プロジェクト: ecmnet/MAVComm
 {
   schedThPoolExec.prestartAllCoreThreads();
   schedThPoolExec.setKeepAliveTime(0, TimeUnit.SECONDS);
 }