Code example for AtomicInteger

Methods: incrementAndGet

0
            private final AtomicInteger count = new AtomicInteger();
            @Override 
            public Thread newThread(final Runnable runner) {
                final Thread t = new Thread(runner, name+count);
                t.setDaemon(true);
                count.incrementAndGet();
                return t;
            } 
        }); 
    } 
     
    public static ThreadFactory newNonDaemonThreadFactory(final String name) {
        final AtomicInteger counter = new AtomicInteger();
        return new ThreadFactory() {
            @Override 
            public Thread newThread(final Runnable run) {
                return new Thread(run, name + '-' + counter.getAndIncrement());
            } 
        }; 
    }