Code example for AtomicLong

Methods: compareAndSet

0
    { 
        if(isTransactional()) 
        { 
            //There can currently only be at most one outstanding transaction 
            //due to only having LocalTransaction support. Set value to 1 if 0. 
            _txnCount.compareAndSet(0,1);
        } 
    } 
     
    private void decrementOutstandingTxnsIfNecessary() 
    { 
        if(isTransactional()) 
        { 
            //There can currently only be at most one outstanding transaction 
            //due to only having LocalTransaction support. Set value to 0 if 1. 
            _txnCount.compareAndSet(1,0);
        } 
    } 
 
    /** 
     * Update last transaction activity timestamp