Class ReportSemaphoreHandling

  • All Implemented Interfaces:
    OBProvidable, OBSingleton

    public class ReportSemaphoreHandling
    extends Object
    implements OBSingleton
    A class which can be used to limit the number of parallel processes running. If no semaphore is available an OBException is thrown. This semaphore handler can/should be used by heavy resource intensive reporting processes.To prevent too many to run at the same time. Implementation is based on Semaphore. The acquire() and release() methods should be called using a try finally block:
     
     // call acquire before the try:
     ReportSemaphoreHandling.getInstance().acquire();
     try {
     
     } finally {
       ReportSemaphoreHandling.getInstance().release();
     }
     
     
    Author:
    mtaal
    • Method Detail

      • acquire

        public void acquire()
                     throws OBException
        Increments the threadCounter by one unit. The Max value of the counter can be parameterized by setting the OBUIAPP_MaxReportThreads System preference. If no preference is found or it is wrongly configured DEFAULT_MAX_THREADS default value is used.
        Throws:
        OBException - When the threadCounter is in its max value.
      • release

        public void release()
        Decreases the threadCounter by one unit.