Java ThreadPoolExecutor executeInDaemon(Runnable... run)

Here you can find the source of executeInDaemon(Runnable... run)

Description

execute In Daemon

License

Open Source License

Declaration

public static void executeInDaemon(Runnable... run) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;

public class Main {
    public static void executeInDaemon(Runnable... run) {

        int i = run.length;
        ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(
                i, new ThreadFactory() {

                    @Override/* w w  w .j av  a2s  .  c  o  m*/
                    public Thread newThread(Runnable r) {
                        Thread t = new Thread();
                        t.setDaemon(true);
                        return t;
                    }
                });
        while (--i >= 0) {
            executor.scheduleAtFixedRate(run[i], 0, 40,
                    TimeUnit.MILLISECONDS);
        }

    }
}

Related

  1. createExecutor(final String name, int count, int keepAlive, final boolean isDaemon)
  2. createQueue(final int queueCapacity)
  3. createScheduledThreadPoolExecutor(final int poolSz, final String threadName)
  4. createThreadPoolExecutor(final int queueSize, final String threadName)
  5. executeInBackground(Runnable r)
  6. getBlockingWorkExecutor()
  7. getBoundedThreadPoolExecutor(int maxPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory tFactory)
  8. getScheduler()
  9. getThreadPoolExecutor(int poolSize, int[] poolInfo)