You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ch...@dlr.de on 2003/10/17 16:28:58 UTC

[lang] or [ThreadPool] contribution: ParalellThreadGuard

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