Code example for AtomicInteger

Methods: getAndIncrement

0
    private final int priority;
 
    public LowPriorityThreadFactory() { 
        SecurityManager s = System.getSecurityManager();
        group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
        namePrefix = "lp-pool-" + poolNumber.getAndIncrement() + "-thread-";
        priority = Thread.MIN_PRIORITY + 1;
    } 
 
    public Thread newThread(Runnable r) {
        Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
        if (t.isDaemon())
            t.setDaemon(false);
        if (t.getPriority() != priority)
            t.setPriority(priority);
        return t;
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE