Code example for Semaphore

Methods: acquire, release

0
    /** 
     * Prepare for the beginning of active use of the public methods of this 
     * component.  This method should be called after <code>configure()</code>, 
     * and before any of the public methods of the component are utilized. 
     * 
     * @exception LifecycleException if this component detects a fatal error 
     *  that prevents this component from being used 
     */ 
    public void start() throws LifecycleException { 
 
        // Validate and update our current component state 
        if (started)
            throw new LifecycleException 
                (sm.getString("semaphoreValve.alreadyStarted"));
        lifecycle.fireLifecycleEvent(START_EVENT, null);
        started = true;
 
        semaphore = new Semaphore(concurrency, fairness);
 
    } 
 
 
    /** 
     * Gracefully terminate the active use of the public methods of this 
     * component.  This method should be the last one called on a given 
     * instance of this component. 
     * 
     * @exception LifecycleException if this component detects a fatal error 
     *  that needs to be reported 
     */