Index: java/org/apache/tomcat/util/threads/TaskQueue.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- java/org/apache/tomcat/util/threads/TaskQueue.java (revision 75cec48b92d593b0beed19d3befedf86d497edfa) +++ java/org/apache/tomcat/util/threads/TaskQueue.java (date 1582049473504) @@ -66,14 +66,16 @@ @Override public boolean offer(Runnable o) { - //we can't do any checks - if (parent==null) return super.offer(o); + //we can't do any checks + if (parent == null) return super.offer(o); + // getPoolSize() is expensive call to AbstractQueuedSynchronizer acquire lock + final int poolSize = parent.getPoolSize(); //we are maxed out on threads, simply queue the object - if (parent.getPoolSize() == parent.getMaximumPoolSize()) return super.offer(o); + if (poolSize == parent.getMaximumPoolSize()) return super.offer(o); //we have idle threads, just add it to the queue - if (parent.getSubmittedCount()<=(parent.getPoolSize())) return super.offer(o); + if (parent.getSubmittedCount() <= poolSize) return super.offer(o); //if we have less threads than maximum force creation of a new thread - if (parent.getPoolSize()