users@glassfish.java.net

Servlet and Thread pools

From: <glassfish_at_javadesktop.org>
Date: Sun, 02 May 2010 15:52:44 PDT

Hi,

I'm using Glassfish 3 Web profile and can't get http workers to execute concurrently requests on a servlet.

This is how i observed the problem. I've made a very simple servlet, that writes the current thread name to the standard output and sleep for 10 seconds :

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println(Thread.currentThread().getName());
try {
        Thread.sleep(10000); // 10 sec
}
catch (InterruptedException ex) {}
}

And i clearly see in the logs that the requests are sequentially executed (one trace every 10 seconds).

INFO: http-thread-pool-8080-(2)
(10 seconds later...)
INFO: http-thread-pool-8080-(1)
(10 seconds later...)
INFO: http-thread-pool-8080-(2)

etc.

All my GF settings are untouched - it's the out-of-the-box config (the default thread pool is 2 threads min, 5 max if I recall properly).

...I really don't understand why the sleep() block all the others worker threads. Any insight would be greatly appreciated !

Thanks,

Fabien
[Message sent by forum member 'fabien_b']

http://forums.java.net/jive/thread.jspa?messageID=400005