Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 62570 invoked from network); 1 Jul 2008 14:02:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Jul 2008 14:02:55 -0000 Received: (qmail 40485 invoked by uid 500); 1 Jul 2008 14:02:44 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 40455 invoked by uid 500); 1 Jul 2008 14:02:44 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 40444 invoked by uid 99); 1 Jul 2008 14:02:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jul 2008 07:02:44 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rosenberg.leon@googlemail.com designates 209.85.162.180 as permitted sender) Received: from [209.85.162.180] (HELO el-out-1112.google.com) (209.85.162.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jul 2008 14:01:50 +0000 Received: by el-out-1112.google.com with SMTP id y26so110502ele.18 for ; Tue, 01 Jul 2008 07:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=VyPz4724lR6yWoH5QIVW4SCV42xfyTLzoU0PW8oj5N8=; b=WxyuKDXEd6S4iDcQXNqp7TR0Qr7RhPiZDwJjLDQkr02/6w6OPuldhlajOJioEiX9Nw TIoQSWm1U1g9lbk8mUjmqfmxT3xg+jEvjskQ+I+JWNw9G9LutDiqC9Apkv2xT3nXuolI yGTnS/UXWwqN58/5zTqtNfVAASDGHngzipZNA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=Xl+/GIt3W28U0/Ss2iBY3UwElMy4nW0htB+WRv0iAnLzTkZp7sBsCS6vVouK82RgpM WiyKvjl5EPptDdVTTGUwYGogKCk15VuCdB+H8/be6f9NIvtDTlXlDgCZ5YBLtW/m8wAM AhRliQn4lk6JUVWxwZmtiHQGFkeOEnoKBeZ34= Received: by 10.151.156.15 with SMTP id i15mr10609361ybo.162.1214920886570; Tue, 01 Jul 2008 07:01:26 -0700 (PDT) Received: by 10.150.220.10 with HTTP; Tue, 1 Jul 2008 07:01:26 -0700 (PDT) Message-ID: <327858f40807010701l316b6da4u4dd0889aba64847d@mail.gmail.com> Date: Tue, 1 Jul 2008 16:01:26 +0200 From: "Leon Rosenberg" To: "Tomcat Users List" Subject: Re: Blocking threads in Tomcat In-Reply-To: <1214918208.3679.27.camel@pc7.dolda2000.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1214885479.3679.12.camel@pc7.dolda2000.com> <327858f40806302346i4d666665mcd007770d8e21107@mail.gmail.com> <1214918208.3679.27.camel@pc7.dolda2000.com> X-Virus-Checked: Checked by ClamAV on apache.org interesting, can you provide your webapp + configs for download and test? Leon On Tue, Jul 1, 2008 at 3:16 PM, Fredrik Tolf wrote: > On Tue, 2008-07-01 at 08:46 +0200, Leon Rosenberg wrote: >> Hello Frederic, >> >> unless you are using the SingleThreaded Model (and you shouldn't) >> tomcat does no such thing. > > There's no way I could be doing any such thing unknowingly, such as it > being the default, right? > >> I assume the best way is to show us your servlet code, or to check for >> synchronized blocks in it. > > The dispatch code is quite simple: > > protected void doGet(HttpServletRequest req, HttpServletResponse resp) { > try { > req.setCharacterEncoding("UTF-8"); > resp.setCharacterEncoding("UTF-8"); > } catch(UnsupportedEncodingException e) { > throw(new AssertionError(e)); > } > try { > if(req.getPathInfo().equals("/")) { > redirect(req, resp, "/ls"); > } else if(req.getPathInfo().equals("/ls")) { > req.setAttribute("db", load()); > Thread.sleep(10000); > getServletContext().getNamedDispatcher("index") > .forward(req, resp); > } else if(req.getPathInfo().equals("/adm")) { > req.setAttribute("db", load()); > Thread.sleep(10000); > getServletContext().getNamedDispatcher("admin") > .forward(req, resp); > } else if(req.getPathInfo().equals("/css")) { > getServletContext().getNamedDispatcher("style") > .forward(req, resp); > } else { > error(req, resp, 404, "Resource not found"); > } > } catch(Exception e) { > log("Caught exception", e); > error(req, resp, 500, "Internal error"); > } > } > > You can see the Thread.sleep calls that I mentioned. The `load' function > does no synchronization whatsoever. > > I followed Steffen Heil's advice on sending a SIGQUIT to Tomcat to get > the thread dump, and the results are as follows: > > When I'm running one request to "/ls" and one to "/adm" simultaneously, > there are indeed two threads in the doGet function above, one sleeping > on the first Thread.sleep call and one on sleeping on the other. > > When, on the other hand, I'm running two requests to "/ls" > simultaneously, there is only one thread from the pool in the doGet > function. All other threads in the pool are sleeping with the following > stack trace: > > java.lang.Thread.State: WAITING (on object monitor) > at java.lang.Object.wait(Native Method) > - waiting on <0x95401098> (a org.apache.tomcat.util.threads.ThreadPool > $ControlRunnable) > at java.lang.Object.wait(Object.java:485) > at org.apache.tomcat.util.threads.ThreadPool > $ControlRunnable.run(ThreadPool.java:656) > - locked <0x95401098> (a org.apache.tomcat.util.threads.ThreadPool > $ControlRunnable) > at java.lang.Thread.run(Thread.java:619) > > Except one, which is trying to accept a connection from the listening > socket, but that seems to be the idle condition (it does that when I'm > running the dual requests to "/ls" and "/adm" as well). > > By the way, this is Tomcat 5.5.17. Might that matter? > > Fredrik Tolf > > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org