Code example for AtomicInteger

Methods: getAndSet

    private static class TestListener implements Runnable {
        private final AtomicInteger callCount;
        public TestListener() { 
            this.callCount = new AtomicInteger(0);
        public int getAndResetCallCount() { 
            return callCount.getAndSet(0);
        public void verifyCalledAndReset() { 
            assertTrue("Listener must have been notified.", getAndResetCallCount() > 0); 
        public void run() { 
Stop searching for code, let great code find you!  Add Codota to your java IDE