Code example for AtomicLong

Methods: addAndGetget

0
        _messageCredit.set(0L);
    } 
 
    public boolean hasCredit() 
    { 
        return _messageCredit.get() > 0L;
    } 
 
    public boolean useCreditForMessage(ServerMessage msg)
    { 
        if(hasCredit()) 
        { 
            if(_messageCredit.addAndGet(-1L) >= 0)
            { 
                setSuspended(false); 
                return true; 
            } 
            else 
            { 
                _messageCredit.addAndGet(1L);
                setSuspended(true); 
                return false; 
            } 
        } 
        else 
Contextual code suggestions in your IDE  Get Codota for Java