public class InterruptibleMulticoreWrapper<I,O> extends MulticoreWrapper<I,O>
|Constructor and Description|
Create an interruptible thread pool for multithreaded processing.
|Modifier and Type||Method and Description|
After a shutdown request, await for the final termination of all threads.
Returns the next available thread id.
Shuts down the thread pool, returns when finished.
join, join, nThreads, peek, poll, put, toString
public InterruptibleMulticoreWrapper(int numThreads, ThreadsafeProcessor<I,O> processor, boolean orderResults, long timeout)
numThreads- If less than or equal to 0, then automatically determine the number of threads. Otherwise, the size of the underlying threadpool.
processor- The processor (factory) for what will be run on data.
orderResults- If true, return results in the order submitted. Otherwise, return results as they become available.
timeoutis a positive number, the threadpool attempts to allow jobs to run for only this many milliseconds, but it depends on threads being Interruptible to succeed. If zero or negative, thread runtime is unlimited.
protected ThreadPoolExecutor buildThreadPool(int nThreads)
protected Integer getProcessor()
timeout is positive, then
join waits at
timeout milliseconds for threads to finish. If
any fail to finish in that time, the threadpool is shutdownNow.
join continues to wait for the
interrupted threads to finish, so if job do not obey
interruptions, they can continue indefinitely regardless of the
timeoutwas reached, or an empty list if that did not happen.
Stanford NLP Group