Java Thread Executor Create createResourceRetrievalService( final String threadName)

Here you can find the source of createResourceRetrievalService( final String threadName)

Description

Convenience method to create a java.util.concurrent.ScheduledExecutorService which can be used by World Wind components to schedule periodic resource checks.

License

Open Source License

Parameter

Parameter Description
threadName the String name for the ExecutorService's thread, may be <code>null</code>.

Return

a new ScheduledExecutorService appropriate for scheduling periodic resource checks.

Declaration

public static ScheduledExecutorService createResourceRetrievalService(
        final String threadName) 

Method Source Code

//package com.java2s;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;

public class Main {
    /**//from ww w. j  a  v a2s.  c  o m
     * Convenience method to create a {@link java.util.concurrent.ScheduledExecutorService} which can be used by World
     * Wind components to schedule periodic resource checks. The returned ExecutorService is backed by a single daemon
     * thread with minimum priority.
     *
     * @param threadName the String name for the ExecutorService's thread, may be <code>null</code>.
     * @return a new ScheduledExecutorService appropriate for scheduling periodic resource checks.
     */
    public static ScheduledExecutorService createResourceRetrievalService(
            final String threadName) {
        ThreadFactory threadFactory = new ThreadFactory() {
            public Thread newThread(Runnable r) {
                Thread thread = new Thread(r);
                thread.setDaemon(true);
                thread.setPriority(Thread.MIN_PRIORITY);

                if (threadName != null) {
                    thread.setName(threadName);
                }

                return thread;
            }
        };

        return Executors.newSingleThreadScheduledExecutor(threadFactory);
    }
}

Related

  1. createEventsOrderedDeliveryExecutor()
  2. createExecutor()
  3. createExecutor(final String file)
  4. createExecutors(int numThreads)
  5. createExecutorService()
  6. createSingleThreadExecutor(final String name)
  7. createStatisticsExecutor()
  8. createThreadFactory(final String prefix)
  9. getExecutor()