Code example for AtomicInteger

Methods: getAndSet

0
            return this.state.compareAndSet(MonitoredThreadState.RUNNING.ordinal(),
                MonitoredThreadState.STUCK.ordinal());
        } 
 
        public MonitoredThreadState markAsDone() { 
            int val = this.state.getAndSet(MonitoredThreadState.DONE.ordinal());
            return MonitoredThreadState.values()[val];
        } 
 
        boolean isMarkedAsStuck() { 
            return this.state.get() == MonitoredThreadState.STUCK.ordinal();
        } 
    } 
 
    private static class CompletedStuckThread { 
 
        private final String threadName;
        private final long totalActiveTime;
 
        public CompletedStuckThread(String threadName, long totalActiveTime) {
            this.threadName = threadName;