<Configure> <!-- =========================================================== --> <!-- Configure the Server Thread Pool. --> <!-- The server holds a common thread pool which is used by --> <!-- default as the executor used by all connectors and servlet --> <!-- dispatches. --> <!-- --> <!-- Configuring a fixed thread pool is vital to controlling the --> <!-- maximal memory footprint of the server and is a key tuning --> <!-- parameter for tuning. In an application that rarely blocks --> <!-- then maximal threads may be close to the number of 5*CPUs. --> <!-- In an application that frequently blocks, then maximal --> <!-- threads should be set as high as possible given the memory --> <!-- available. --> <!-- --> <!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool --> <!-- for all configuration that may be set here. --> <!-- =========================================================== --> <Newid="threadPool"class="org.eclipse.jetty.util.thread.QueuedThreadPool"> <Setname="minThreads"type="int"><Propertyname="jetty.threadPool.minThreads"deprecated="threads.min"default="10"/></Set> <Setname="maxThreads"type="int"><Propertyname="jetty.threadPool.maxThreads"deprecated="threads.max"default="200"/></Set> <Setname="reservedThreads"type="int"><Propertyname="jetty.threadPool.reservedThreads"default="-1"/></Set> <Setname="idleTimeout"type="int"><Propertyname="jetty.threadPool.idleTimeout"deprecated="threads.timeout"default="60000"/></Set> <Setname="detailedDump"type="boolean"><Propertyname="jetty.threadPool.detailedDump"default="false"/></Set> </New> </Configure>
while (true) { if (job == null) { if (!idle) { idle = true; _threadsIdle.incrementAndGet(); }
if (_idleTimeout <= 0) job = _jobs.take(); else { // maybe we should shrink? int size = _threadsStarted.get(); if (size > _minThreads) { long last = _lastShrink.get(); long now = System.nanoTime(); if (last == 0 || (now - last) > TimeUnit.MILLISECONDS.toNanos(_idleTimeout)) { if (_lastShrink.compareAndSet(last, now)) break; } }