commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph.R...@dlr.de
Subject [lang] or [ThreadPool] contribution: ParalellThreadGuard
Date Fri, 17 Oct 2003 14:28:58 GMT
A common problem for networked applications accepting multiple
connections in individual threads that cannot control the
socket accept() paralellity (as the JDK1.4 ORB) need to restrict
the resources somewhere else.

For this purpose we designed a ParalellThreadGuard class that
can be used as follows:

   private ParalellThreadGuard guard =
     new ParalellThreadGuard(THREADS_ACTIVE, THREADS_ENQUEUE, THREADS_TIMEOUT);
...
   public void guardedMethod() throws RejectedException
   {
     guard.register(); // might throw a RejectedException
     try
     {
       ... // do something with your limited resources here
     }
     finally
     {
       guard.release();
     }
   }


This class seems to fit to the [lang] area, but might also
fit in the scope of the sandboxed [ThreadPool] package.

I can contribute it to Apache with the proper licence header
if someone sees it fitting.

Cheers,
Christoph Reck

Mime
View raw message