Code example for AtomicInteger

Methods: decrementAndGet, get, incrementAndGet

0
            (ConcurrentHashMap<String,CachedStatement>)pcon.getAttributes().get(STATEMENT_CACHE_ATTR);
        if (proxy.getSql()==null) {
            return false; 
        } else if (cache.containsKey(proxy.getSql())) {
            return false; 
        } else if (cacheSize.get()>=maxCacheSize) {
            return false; 
        } else if (cacheSize.incrementAndGet()>maxCacheSize) {
            cacheSize.decrementAndGet();
            return false; 
        } else { 
            //cache the statement 
            cache.put(proxy.getSql(), proxy);
            return true; 
        } 
    } 
 
    public boolean removeStatement(CachedStatement proxy) {
        ConcurrentHashMap<String,CachedStatement> cache =
            (ConcurrentHashMap<String,CachedStatement>)pcon.getAttributes().get(STATEMENT_CACHE_ATTR);
        if (cache.remove(proxy.getSql()) != null) {