Code example for AtomicInteger

Methods: incrementAndGet

0
    /** 
     * Increases the ref count, and returns <tt>true</tt> if it managed to 
     * actually increment it. 
     */ 
    public boolean increaseRefCount() { 
        return refCount.incrementAndGet() > 1;
    } 
 
    public void decreaseRefCount(boolean delete) {
        if (refCount.decrementAndGet() <= 0) {
            try { 
                raf.close();
                if (delete) {
                    file.delete();
                } 
            } catch (IOException e) {
                // ignore 
            } 
        } 
    }