public class AtmostOneThreadExecutor extends AbstractExecutorService
ExecutorService that uses at most one executor.
Compared to Executors.newFixedThreadPool(1), this code will not keep
the thread around if it's not doing anything, freeing up resources.
| Constructor and Description |
|---|
AtmostOneThreadExecutor() |
AtmostOneThreadExecutor(ThreadFactory factory) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
execute(Runnable command) |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitpublic AtmostOneThreadExecutor(ThreadFactory factory)
public AtmostOneThreadExecutor()
public void shutdown()
public boolean isShutdown()
public boolean isTerminated()
public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
InterruptedExceptionpublic void execute(Runnable command)
Copyright © 2004–2017. All rights reserved.