Code example for AtomicInteger

Methods: getAndIncrement

0
 
    private static final ThreadFactory sThreadFactory = new ThreadFactory() {
        private final AtomicInteger mCount = new AtomicInteger(1); 
 
        public Thread newThread(Runnable r) { 
            return new Thread(r, "StartupNews thread #" + mCount.getAndIncrement()); 
        } 
    }; 
 
    private ExecutorService mExecutorService;
 
    private static MyApplication me;
 
    public static MyApplication instance() { 
        return me;
    } 
 
    public MyApplication() { 
        super(); 
        me = this;
    }