https://bz.apache.org/bugzilla/show_bug.cgi?id=64155

--- Comment #3 from Torres Yang <torres.y...@broadcom.com> ---
Hi Mark,


Thanks for your prompt reply, o.a.t.u.threads.ThreadPoolExecutor indeed extends
the j.u.c.ThreadPoolExecutor, and it inherits the getPoolSize() from
j.u.c.ThreadPoolExecutor as well.

However, the j.u.c.ThreadPoolExecutor's getPoolSize() implementation has
ReentrantLock in-placed.


Here is the code from Java 8:

    /**
     * Returns the current number of threads in the pool.
     *
     * @return the number of threads
     */
    public int getPoolSize() {
        final ReentrantLock mainLock = this.mainLock;
        mainLock.lock();
        try {
            // Remove rare and surprising possibility of
            // isTerminated() && getPoolSize() > 0
            return runStateAtLeast(ctl.get(), TIDYING) ? 0
                : workers.size();
        } finally {
            mainLock.unlock();
        }
    }


It's very obvious that whenever go into this function, it must first obtain the
lock before anything.


Hope this explain your question or concern.



Bests,


Torres

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to