For IntelliJ IDEA and
Android Studio


@SuppressWarnings("deprecation") protected ThreadPoolConfig updateFrom(ExtendedThreadPool ep) { this.queue = ep.getQueue(); this.threadFactory = ep.getThreadFactory(); this.poolName = ep.getName(); this.maxPoolSize = ep.getMaximumPoolSize(); //hiding internal values, due to they might not match configure //this.queueLimit = ep.getMaxQueuedTasksCount(); //this.corepoolsize = ep.getCorePoolSize(); //this.keepAliveTime = keepAliveTime; //this.timeUnit = timeUnit; //this.monitoringProbe = monitoringProbe; return this; }
/** * sets the default ThreadPool that DefaultNotificationHandler use. * shutdownNow is called on the existing ThreadPool. * does not update existing notification handlers. */ public final void setThreadPool(ExtendedThreadPool pool) { if (pool != null) { if (threadPool != null) { threadPool.shutdownNow(); } threadPool = pool; SelectorFactory.setMaxSelectors(pool.getMaximumPoolSize()); } }
maxPoolSize = ((ExtendedThreadPool) threadPool).getMaximumPoolSize();
private void ensureAppropriatePoolSize( ExecutorService threadPool ) { if( threadPool == null ) return; if( threadPool instanceof GrizzlyExecutorService ) { final GrizzlyExecutorService grizzlyExecutorService = (GrizzlyExecutorService) threadPool; final ThreadPoolConfig config = grizzlyExecutorService.getConfiguration(); if( config.getCorePoolSize() < requiredThreadsCount ) { if( config.getMaxPoolSize() < requiredThreadsCount ) config.setMaxPoolSize( requiredThreadsCount ); config.setCorePoolSize( requiredThreadsCount ); grizzlyExecutorService.reconfigure(config); } } else if( threadPool instanceof ExtendedThreadPool ) { final ExtendedThreadPool extendedThreadPool = (ExtendedThreadPool)threadPool; if( extendedThreadPool.getCorePoolSize() < requiredThreadsCount ) { if( extendedThreadPool.getMaximumPoolSize() < requiredThreadsCount ) extendedThreadPool.setMaximumPoolSize( requiredThreadsCount ); extendedThreadPool.setCorePoolSize( requiredThreadsCount ); } } else if( threadPool instanceof ThreadPoolExecutor ) { final ThreadPoolExecutor jdkThreadPool = (ThreadPoolExecutor)threadPool; if( jdkThreadPool.getCorePoolSize() < requiredThreadsCount ) { if( jdkThreadPool.getMaximumPoolSize() < requiredThreadsCount ) jdkThreadPool.setMaximumPoolSize( requiredThreadsCount ); jdkThreadPool.setCorePoolSize( requiredThreadsCount ); } } }
if (p instanceof ExtendedThreadPool) { ExtendedThreadPool threadPool = (ExtendedThreadPool) p; int maxThreads = threadPool.getMaximumPoolSize();
float threadRatio = (float) st.getActiveCount() / (float) st.getMaximumPoolSize();