Code example for AtomicInteger

Methods: getAndIncrementset

0
        this.monitor = monitor;
        count = new AtomicInteger(0);
    } 
 
    public void run() { 
        if (count.getAndIncrement() == 5) {
            monitor.error(new Exception("An error was raised"));
            count.set(0);
        } else { 
            monitor.message("This is a message");
        } 
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE