public void join() throws InterruptedException { synchronized (_joinLock) { while (isRunning()) _joinLock.wait(); } // TODO remove this semi busy loop! while (isStopping()) Thread.sleep(10); }
/** Set the minimum number of threads. * Delegated to the named or anonymous Pool. * @see #getMinThreads * @param minThreads minimum number of threads */ public void setMinThreads(int minThreads) { if (isStarted() && (minThreads<=0 || minThreads>_maxThreads)) throw new IllegalArgumentException("!0<=minThreads<maxThreads"); _minThreads=minThreads; synchronized (_lock) { while (isStarted() && _threads.size()<_minThreads) { newThread(null); } } }
BoundedThreadPool threadPool = new BoundedThreadPool(); threadPool.setMinThreads(getMinThreadPoolSize()); threadPool.setMaxThreads(getMaxThreadPoolSize()); m_server.setThreadPool(threadPool);
while (isRunning()) if ((now-_lastShrink)>getMaxIdleTimeMs()) this.wait(getMaxIdleTimeMs()); job=_job; _job=null; if (job!=null && isRunning()) BoundedThreadPool.this.dispatch(job);
BoundedThreadPool btp=new BoundedThreadPool(); setThreadPool(btp);
/** Set the maximum number of threads. * Delegated to the named or anonymous Pool. * @see #getMaxThreads * @param maxThreads maximum number of threads. */ public void setMaxThreads(int maxThreads) { if (isStarted() && maxThreads<_minThreads) throw new IllegalArgumentException("!minThreads<maxThreads"); _maxThreads=maxThreads; }
protected void doStart() throws Exception { if (_maxThreads<_minThreads || _minThreads<=0) throw new IllegalArgumentException("!0<minThreads<maxThreads"); _threads=new HashSet(); _idle=new ArrayList(); _queue=new LinkedList(); for (int i=0;i<_minThreads;i++) { newThread(null); } }