Code example for ConcurrentLinkedQueue

0
    private final Queue<T> outQueue;
    private final Handler<T> handler; 
 
    public ConcurrentBuffer(final Handler<T> handler) { 
        this.handler = handler;
        outQueue = new ConcurrentLinkedQueue<T>();
    } 
 
    public boolean isOpen() { 
        return true; 
    } 
 
    public void handle(final T t) throws HandlerException {
        outQueue.add(t);
    } 
 
    public boolean flush() throws HandlerException { 
        int size = outQueue.size();
 
        for (int i = 0; i < size; i++) {
            if (!handler.isOpen()) {