Code example for AtomicLong

Methods: addAndGet

0
        public BrowserDefinition getByUserAgent(@Nonnull String userAgent) {
            final long startTimeInMillis = System.currentTimeMillis();
            try { 
                return super.getByUserAgent(userAgent);
            } finally { 
                _totalMilliSecondsOfCallsOfGetUserAgent.addAndGet(System.currentTimeMillis() - startTimeInMillis);
                _countOfCallsOfGetUserAgent.incrementAndGet();
            } 
        } 
         
        @Nonnegative 
        private long getTotalMilliSecondsOfCallsOfGetUserAgent() { 
            return _totalMilliSecondsOfCallsOfGetUserAgent.get();
        } 
 
        @Nonnegative 
        private int getCountOfCallsOfGetUserAgent() { 
            return _countOfCallsOfGetUserAgent.get();
        } 
 
        @Nonnegative