@Test public void testJdkThreadExecutor(){ int minThread = 2; int maxThead = 10; ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(maxThead); ThreadPoolExecutor executor = new ThreadPoolExecutor(minThread,maxThead, 60, TimeUnit.SECONDS,queue,Executors.defaultThreadFactory()); for(int i=0;i<minThread;i++){ executor.submit(new SleepTask(10000)); } Assert.assertEquals(minThread,executor.getPoolSize()); for(int i=minThread;i<maxThead;i++){ executor.submit(new SleepTask(10000)); } Assert.assertEquals(2,executor.getPoolSize()); Assert.assertEquals(8,queue.size()); for(int i=0;i<maxThead;i++){ executor.submit(new SleepTask(10000)); } Assert.assertEquals(maxThead,executor.getPoolSize()); try{ executor.submit(new SleepTask(10000)); Assert.fail(); }catch(RejectedExecutionException e){ Assert.assertTrue(true); } }
public int getPoolSize() { return executor.getPoolSize(); }
StandardThreadExecutor extends java.util.concurrent.AbstractExecutorService { public int getPoolSize() { return executor.getPoolSize(); } }
StandardThreadExecutor extends java.util.concurrent.AbstractExecutorService { public int getPoolSize() { return executor.getPoolSize(); } StandardThreadExecutor();  StandardThreadExecutor(int minSpareThreads,int maxThreads);  StandardThreadExecutor(int minSpareThreads,int maxThreads,int taskQueueCapacity); }
StandardThreadExecutor extends java.util.concurrent.AbstractExecutorService { public int getPoolSize() { return executor.getPoolSize(); } StandardThreadExecutor();  StandardThreadExecutor(int minSpareThreads,int maxThreads);  StandardThreadExecutor(int minSpareThreads,int maxThreads,int taskQueueCapacity); void execute(Runnable command); int getThreadPriority(); boolean isDaemon(); String getNamePrefix(); int getMaxIdleTime(); int getMaxThreads(); int getMinSpareThreads(); String getName(); void setThreadPriority(int threadPriority); void setDaemon(boolean daemon); void setNamePrefix(String namePrefix); void setMaxIdleTime(int maxIdleTime); void setMaxThreads(int maxThreads); void setMinSpareThreads(int minSpareThreads); void setName(String name); int getActiveCount(); int getSubmittedTasksCount(); long getCompletedTaskCount(); int getCorePoolSize(); int getLargestPoolSize(); int getPoolSize(); int getQueueSize(); int getQueueCapacity(); @Override void shutdown(); @Override List<Runnable> shutdownNow(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override boolean awaitTermination(long timeout, TimeUnit unit); }
StandardThreadExecutor extends java.util.concurrent.AbstractExecutorService { public int getPoolSize() { return executor.getPoolSize(); } StandardThreadExecutor();  StandardThreadExecutor(int minSpareThreads,int maxThreads);  StandardThreadExecutor(int minSpareThreads,int maxThreads,int taskQueueCapacity); void execute(Runnable command); int getThreadPriority(); boolean isDaemon(); String getNamePrefix(); int getMaxIdleTime(); int getMaxThreads(); int getMinSpareThreads(); String getName(); void setThreadPriority(int threadPriority); void setDaemon(boolean daemon); void setNamePrefix(String namePrefix); void setMaxIdleTime(int maxIdleTime); void setMaxThreads(int maxThreads); void setMinSpareThreads(int minSpareThreads); void setName(String name); int getActiveCount(); int getSubmittedTasksCount(); long getCompletedTaskCount(); int getCorePoolSize(); int getLargestPoolSize(); int getPoolSize(); int getQueueSize(); int getQueueCapacity(); @Override void shutdown(); @Override List<Runnable> shutdownNow(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override boolean awaitTermination(long timeout, TimeUnit unit); static final int DEFAULT_MIN_SPARE_THREADS; static final int DEFAULT_MAX_THREADS; }