/** * Nonblocking get the next object * * @return null of there is no data or the next available object */ public T read() { synchronized (access) { if (rpos == wpos) return null; return get(); } }
/** * Get all data available from the buffer * @return */ public ArrayList<T> readAll() { synchronized (access) { int size = getAvailable(); ArrayList<T> result = new ArrayList<>(); for( int i=0; i<size; i++) result.add(get()); return result; } }