/** * Removes the next value from the buffer, waiting until an object is * added if the buffer is empty. This method uses the default timeout * set in the constructor. * * @throws BufferUnderflowException if an interrupt is received */ public Object remove() { synchronized (lock) { while (collection.isEmpty()) { try { if (timeout <= 0) { lock.wait(); } else { return remove(timeout); } } catch (InterruptedException e) { PrintWriter out = new PrintWriter(new StringWriter()); e.printStackTrace(out); throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } return getBuffer().remove(); } }
/** * Removes the next value from the buffer, waiting until an object is * added if the buffer is empty. This method uses the default timeout * set in the constructor. * * @throws BufferUnderflowException if an interrupt is received */ public Object remove() { synchronized (lock) { while (collection.isEmpty()) { try { if (timeout <= 0) { lock.wait(); } else { return remove(timeout); } } catch (InterruptedException e) { PrintWriter out = new PrintWriter(new StringWriter()); e.printStackTrace(out); throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } return getBuffer().remove(); } }
public void testTimeoutRemove() { final BlockingBuffer buffer = new BlockingBuffer( new MyBuffer() ); try { buffer.remove( 100 ); fail( "Get should have timed out." ); } catch( BufferUnderflowException e ) { } }
/** * Removes the next value from the buffer, waiting until an object is * added if the buffer is empty. This method uses the default timeout * set in the constructor. * * @throws BufferUnderflowException if an interrupt is received */ public Object remove() { synchronized (lock) { while (collection.isEmpty()) { try { if (timeout <= 0) { lock.wait(); } else { return remove(timeout); } } catch (InterruptedException e) { PrintWriter out = new PrintWriter(new StringWriter()); e.printStackTrace(out); throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } return getBuffer().remove(); } }
/** * Removes the next value from the buffer, waiting until an object is * added if the buffer is empty. This method uses the default timeout * set in the constructor. * * @throws BufferUnderflowException if an interrupt is received */ public Object remove() { synchronized (lock) { while (collection.isEmpty()) { try { if (timeout <= 0) { lock.wait(); } else { return remove(timeout); } } catch (InterruptedException e) { PrintWriter out = new PrintWriter(new StringWriter()); e.printStackTrace(out); throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } return getBuffer().remove(); } }
/** * Removes the next value from the buffer, waiting until an object is * added if the buffer is empty. This method uses the default timeout * set in the constructor. * * @throws BufferUnderflowException if an interrupt is received */ public Object remove() { synchronized (lock) { while (collection.isEmpty()) { try { if (timeout <= 0) { lock.wait(); } else { return remove(timeout); } } catch (InterruptedException e) { PrintWriter out = new PrintWriter(new StringWriter()); e.printStackTrace(out); throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } return getBuffer().remove(); } }
/** * Removes the next value from the buffer, waiting until an object is * added if the buffer is empty. This method uses the default timeout * set in the constructor. * * @throws BufferUnderflowException if an interrupt is received */ public Object remove() { synchronized (lock) { while (collection.isEmpty()) { try { if (timeout <= 0) { lock.wait(); } else { return remove(timeout); } } catch (InterruptedException e) { PrintWriter out = new PrintWriter(new StringWriter()); e.printStackTrace(out); throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } return getBuffer().remove(); } }
/** * Removes the next value from the buffer, waiting until an object is * added if the buffer is empty. This method uses the default timeout * set in the constructor. * * @throws BufferUnderflowException if an interrupt is received */ public Object remove() { synchronized (lock) { while (collection.isEmpty()) { try { if (timeout <= 0) { lock.wait(); } else { return remove(timeout); } } catch (InterruptedException e) { PrintWriter out = new PrintWriter(new StringWriter()); e.printStackTrace(out); throw new BufferUnderflowException("Caused by InterruptedException: " + out.toString()); } } return getBuffer().remove(); } }