Code example for Semaphore

Methods: acquirerelease

0
     * 
     * @return 
     * @throws Exception 
     */ 
    public MessageOutputStream acquireChannelMessageOutputStream() throws Exception { 
        this.channelWriteSemaphore.acquire();
        try { 
            return this.channel.writeMessage();
        } catch (Exception e) {
            // release 
            this.channelWriteSemaphore.release();
            throw e;
        } 
    } 
 
    /** 
     * Releases a previously held permit/lock on a message outputstream of a channel and also closes 
     * the <code>messageOutputStream</code> 
     * 
     * @param messageOutputStream The message outputstream