All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rx.bean.AbstractReferenceCounter Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package org.rx.bean;

import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;

//Save memory
public abstract class AbstractReferenceCounter {
    protected static final AtomicIntegerFieldUpdater updater = AtomicIntegerFieldUpdater.newUpdater(AbstractReferenceCounter.class, "refCnt");

    protected volatile int refCnt;

    public int getRefCnt() {
        return updater.get(this);
    }

    public int incrementRefCnt() {
        return updater.incrementAndGet(this);
    }

    public int decrementRefCnt() {
        return updater.decrementAndGet(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy