Code example for AtomicLong

Methods: get, set

0
    { 
        long r = requests.get();
        long h = hits.get();
        try 
        { 
            return ((double)(h - lastHits.get())) / (r - lastRequests.get());
        } 
        finally 
        { 
            lastRequests.set(r);
            lastHits.set(h);
        } 
    } 
 
    public void clear() 
    { 
        map.clear();
        requests.set(0);
        hits.set(0);
    }