Code example for AtomicInteger

Methods: addAndGetget

0
            throw new IllegalArgumentException();
        int read = length() - available();
        int newConsumed = consumed() + delta;
//        if (newConsumed > read) 
//            throw new IllegalStateException("Consuming without reading: consumed " + newConsumed + " but only read " + read); 
        consumed.addAndGet(delta);
    } 
 
    /** 
     * @return the number of bytes consumed 
     */ 
    public int consumed() 
    { 
        return consumed.get();
    } 
 
    /** 
     * 
     * @param charset the charset used to convert the bytes 
     * @param consume whether to consume the content