public class CrawlerExecutor extends ThreadPoolExecutor
ThreadPoolExecutor to implement the beforeExecute, afterExecute
and terminated. Every time a new Crawler is added to this Executor by its
ThreadPoolExecutor.execute(Runnable) function a new Thread is created when there are no more free threads.
If there is a free (old) unused thread left the Crawler will be loaded into that Thread. So
Threads will be reused, at most numberOfThreads will be created. The number of Crawlers active at
the same time will be the maximum of the number of Threads. If there are no more Threads left,
Crawlers will be stored in a workQueue until a Thread will become available.ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Constructor and Description |
|---|
CrawlerExecutor(BrowserConfiguration config)
Default CrawlerExecutor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
protected void |
beforeExecute(Thread t,
Runnable r) |
boolean |
isAborted() |
List<Runnable> |
shutdownNow(boolean isAbort)
shutdown the CrawlerExecutor, depending on the argument issue a abort or normal shutdown.
|
protected void |
terminated() |
void |
waitForTermination()
This function blocks until all tasks has been executed.
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitpublic CrawlerExecutor(BrowserConfiguration config)
protected void afterExecute(Runnable r, Throwable t)
afterExecute in class ThreadPoolExecutorprotected void beforeExecute(Thread t, Runnable r)
beforeExecute in class ThreadPoolExecutorprotected void terminated()
terminated in class ThreadPoolExecutorpublic void waitForTermination()
throws InterruptedException
InterruptedException - when this thread is interrupted.public List<Runnable> shutdownNow(boolean isAbort)
isAbort - if set to true indicating this is abort instead of normal shutdown.public boolean isAborted()
Copyright © 2007-2013. All Rights Reserved.