public void put(Object x) throws InterruptedException { if (x == null) throw new IllegalArgumentException(); if (Thread.interrupted()) throw new InterruptedException(); putGuard_.acquire(); try { insert(x); takeGuard_.release(); } catch (ClassCastException ex) { putGuard_.release(); throw ex; } }
public Object take() throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); takeGuard_.acquire(); try { Object x = extract(); putGuard_.release(); return x; } catch (ClassCastException ex) { takeGuard_.release(); throw ex; } }