} catch(IllegalMonitorStateException ex) { throw ex;
    public Object remove() throws QueueClosedException {        /*initialize the return value*/        Object retval=null;        /*lock the queue*/        synchronized(mutex) {            /*wait as long as the queue is empty. return when an element is present or queue is closed*/            while(size == 0) {                if(closed)                    throw new QueueClosedException();                try {                    mutex.wait();                }                catch(IllegalMonitorStateException ex) {                    throw ex;                }                catch(InterruptedException ex) {                }            }            if(closed)                throw new QueueClosedException();            /*remove the head from the queue, if we make it to this point, retval should not be null !*/            retval=removeInternal();            if(retval == null)                if(log.isErrorEnabled()) log.error("element was null, should never be the case");        }        /*         * we ran into an Endmarker, which means that the queue was closed before         * through close(true)         */        if(retval == endMarker) {            close(false); // mark queue as closed            throw new QueueClosedException();        }        /*return the object*/        return retval;    }