List of utility methods to do Thread Executor Execute
void | ExecuteThreads(ArrayList Execute Threads ExecutorService tpes = getThreadExecutor(nThreads); for (Thread thread : threads) { tpes.execute(thread); tpes.shutdown(); try { tpes.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { ... |
void | invokeAsync(Runnable runnable) Execute runnable case in async. synchronized (executorService) {
executorService.submit(runnable);
|
void | invokeLater(Runnable runnable) invoke Later executorService.execute(runnable); |
void | invokeOnBackgroundThread(Runnable runnable) invoke On Background Thread ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(runnable); executor.shutdown(); |
void | run(Runnable target) run cachedThreadPool.execute(target); |
void | runConcurrently(final Runnable[] threads) Use a thread pool to concurrently execute threads. final ExecutorService pool = Executors.newFixedThreadPool(threads.length); for (final Runnable thread : threads) { pool.submit(thread); pool.shutdown(); |
void | runConcurrently(Runnable... tasks) run Concurrently ExecutorService executor = Executors.newFixedThreadPool(tasks.length); CountDownLatch allTasksStarted = new CountDownLatch(tasks.length); try { List<Future<?>> futures = new ArrayList<>(); for (Runnable task : tasks) { futures.add(executor.submit(() -> { sync(allTasksStarted, 1000); task.run(); ... |
void | runInBackground(final Runnable task) run In Background final ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(task);
|
Future> | runInBackground(Runnable run) run In Background return workerPool.submit(run);
|
void | runInNewThread(Runnable task) Runs a Runnable task in a Thread different than the current one. pool.submit(task); |