/** * put single byte. Block until the space is available. * * @param value */ @SuppressWarnings("unused") public void put(int value) { synchronized (access) { while (advance(wpos) == rpos) try { access.wait(); } catch (InterruptedException e) { e.printStackTrace(); } data[wpos] = (byte) (value & 0xFF); wpos = advance(wpos); access.notifyAll(); } }
/** * Get the next byte, block until available. */ @SuppressWarnings("unused") public int get() { synchronized (access) { while (rpos == wpos) try { access.wait(); } catch (InterruptedException e) { } int result = data[rpos] & 0xFF; rpos = advance(rpos); access.notifyAll(); return result; } }