Code example for AtomicInteger

     * {@link ThreadFactory} which sets a meaningful name for the thread. 
    private static class BackgroundLoaderThreadFactory implements ThreadFactory {
        private final AtomicInteger mCount = new AtomicInteger(1);
        private final String mTag;
        public BackgroundLoaderThreadFactory(String tag) {
            mTag = tag;
        public Thread newThread(final Runnable r) {
            Thread t =  new Thread(r, mTag + "-" + mCount.getAndIncrement());
            if (t.getPriority() != Thread.MIN_PRIORITY)
            return t;
Stop searching for code, let great code find you!  Add Codota to your java IDE