I just keep track of it myself. Declare a member variable of type int and
increment it everytime a request comes in and decrement it after the request
is serviced (in a finally{} block, watch out for exceptions messing up your
counter).
Make sure you synchronize access to it and it should work just fine.
private synchronized int addThreadCount(int add)
{
return (count += add);
}
... doGet(...)
{
int reportsRunning = addThreadCount(1);
if (reportsRunning > MAX_THREADS)
{
// Sleep thread until ready
}
try
{
// generate report
}
catch (Exception e)
{
// handle exception
}
finally
{
addThreadCount(-1);
}
}
HTH,
Scott
----- Original Message -----
From: "Carter, Will" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 30, 2002 5:50 PM
Subject: RE: Why is FO(P) a superior model than what most proprietary tool s
propose
> this is interesting...
> can the servlet report how many threads it has at any given time? Do you
> know of any code examples of how this is done?
>
> thanks for the good idea...
> will