Code example for AtomicInteger

0
package com.afollestad.silk.images; 
 
import java.util.concurrent.ThreadFactory; 
import java.util.concurrent.atomic.AtomicInteger; 
 
class LowPriorityThreadFactory implements ThreadFactory {
 
    private static final AtomicInteger poolNumber = new AtomicInteger(1);
    private final ThreadGroup group;
    private final AtomicInteger threadNumber = new AtomicInteger(1);
    private final String namePrefix;
    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())