Java Thread Executor Execute execute(Runnable command)

Here you can find the source of execute(Runnable command)

Description

execute

License

BSD License

Declaration

public synchronized static void execute(Runnable command) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class Main {
    public static int DefaultThreads = 8;
    private static ThreadPoolExecutor defaultEs;

    public synchronized static void execute(Runnable command) {
        if (defaultEs == null)
            defaultEs = newExecutor(DefaultThreads);
        defaultEs.execute(command);//  w  ww .  java  2 s  .  c o  m
    }

    public static ThreadPoolExecutor newExecutor(int nThreads) {
        return (ThreadPoolExecutor) Executors.newFixedThreadPool(nThreads);
    }
}

Related

  1. exec(Runnable... commands)
  2. execute(Callable callable)
  3. execute(final Runnable task)
  4. execute(int nThreads, List callables)
  5. execute(Runnable command)
  6. execute(Runnable runnable)
  7. execute(Runnable task)
  8. execute(Runnable task)
  9. execute(String name, Runnable runnable)