public final class ComputerSubmissionHelper extends Object
Constructor and Description |
---|
ComputerSubmissionHelper() |
Modifier and Type | Method and Description |
---|---|
static Future<ComputerResult> |
runWithBackgroundThread(<any> closure,
String threadNameSuffix)
Creates a
Executors.newSingleThreadExecutor(ThreadFactory) configured
make threads that behave like the caller, invokes a closure on it, and shuts it down. |
public static Future<ComputerResult> runWithBackgroundThread(<any> closure, String threadNameSuffix)
Executors.newSingleThreadExecutor(ThreadFactory)
configured
make threads that behave like the caller, invokes a closure on it, and shuts it down.
This is intended to serve as an alternative to ForkJoinPool.commonPool()
,
which is used by CompletableFuture.supplyAsync(Supplier)
(among other methods).
The single threaded executor created by this method contains a thread
with the same context classloader and thread group as the thread that called
this method. Threads created in this method also have predictable behavior when
Thread.setContextClassLoader(ClassLoader)
is invoked; threads in the
common pool throw a SecurityException if the JVM has a security manager configured.
The name of the thread created by this method's internal executor is the concatenation of
threadNameSuffix
parameter valueclosure
- arbitrary code that has exclusive use of the supplied executorthreadNameSuffix
- a string appended to the executor's thread's nameclosure
parameterCopyright © 2013–2016 Apache Software Foundation. All rights reserved.