Code example for AtomicInteger

0
 * @author Derek Smith 
 */ 
public class NamedThreadFactory implements ThreadFactory
{ 
    protected final String id;    
    protected final AtomicInteger n = new AtomicInteger(1);
 
    /** 
     * Creates a new ThreadFactory with a value that can be used 
     * to retrieve itself later. 
     *  
     * @param id The name of the the thread factory; 
     */ 
    public NamedThreadFactory(String id)
    { 
    	super(); 
        this.id = id;
    } 
 
    /* (non-Javadoc) 
     * @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)