FastOdsBus { synchronized public E get() { if (this.isClosed()) { throw new NoSuchElementException(); } while (this.elements.isEmpty()) { try { this.wait(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } return this.elements.remove(); } FastOdsBus(); void close(); synchronized E get(); synchronized boolean isClosed(); synchronized void put(final E element);  }
@Test public void testWaitInterrupt() throws InterruptedException { final FastOdsBus<Integer> b = new FastOdsBus<Integer>(); final Appendable sb = new StringBuilder(); final Thread t1 = new Thread() { @Override public void run() { try { b.get(); Assert.fail(); } catch (final RuntimeException e) { try { sb.append(e.getMessage()); } catch (final IOException e1) { Assert.fail(); } } } }; t1.start(); Thread.sleep(100); t1.interrupt(); t1.join(); Assert.assertEquals("java.lang.InterruptedException", sb.toString()); }