Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 78964 invoked by uid 500); 16 Oct 2001 18:44:13 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: tomcat-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 78872 invoked from network); 16 Oct 2001 18:44:10 -0000 Message-ID: <3BCC7DD6.4079CDC3@cybershop.ca> Date: Tue, 16 Oct 2001 14:35:02 -0400 From: Bo Xu X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: tomcat-user@jakarta.apache.org Subject: Re: Active servlet threads? References: <20011016115950.4089F1BDA9@mail.sctrade.it> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-MDaemon-Deliver-To: tomcat-user@jakarta.apache.org X-Return-Path: bo@cybershop.ca X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N "prs05@prosa.com" wrote: > Hi! > I'd like to know the number of currently active threads of a servlet from within that very servlet... I don't know if I've explained well: I'd like to make a method that counts the active threads, to know in a certain moment how many "servlet copies" are running. I'll use this da Is it possible? I tried with Thread.CurrentThread().getThreadGroup().activeCount(), but it gives me 32, that I guess is the number of the pooled threads, of all the servlet, not only this very one... > may you help me? Thanks! > Germano the following is as a refrence :-) public class MyServlet extends HttpServlet{ private static byte[] locker=new byte[0]; private static int counter; public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException{ synchronized(locker){ counter++; } } }