dsmiley commented on code in PR #4675:
URL: https://github.com/apache/solr/pull/4675#discussion_r3793544549
##########
solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java:
##########
@@ -245,36 +259,104 @@ public static ExecutorService
newMDCAwareCachedThreadPool(String name) {
* Create a new pool of threads, with no limit for the number of threads.
The pool has no task
* queue. Each submitted task is executed immediately, either by reusing an
existing thread if one
* is available, or by starting a new thread. Unused threads will be closed
after 60 seconds.
+ *
+ * <p>Thread count tracks how many tasks run concurrently, but nothing
bounds it: a burst of
+ * simultaneous tasks starts a thread apiece. Only use this where something
upstream already
+ * limits how many tasks can be in flight.
*/
public static ExecutorService newMDCAwareCachedThreadPool(ThreadFactory
threadFactory) {
return new MDCAwareThreadPoolExecutor(
0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>(),
threadFactory);
}
/**
- * Create a new pool of threads. Threads are created for new work if there
is room to do so up to
- * {@code maxThreads}. Beyond that, the queue is used up to {@code
queueCapacity}. Beyond that,
- * work is rejected with an exception. Unused threads will be closed after
60 seconds.
+ * Create a new pool of at most {@code nThreads} threads. Each submitted
task starts a thread
Review Comment:
AI response:
Because core=0 only behaves with a SynchronousQueue. With core=0 + bounded
queue, tasks queue, one rescue thread gets created, and the pool sits at 1
thread until the
queue is full. That's strictly worse than the per-task growth Pierre is
objecting to. So core=0 is not available for newMDCAwareFixedThreadPool —
core==max is forced, which is exactly what the new comment at 270-272 says.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]