Package us.codecraft.webmagic.thread
Class CountableThreadPool
- java.lang.Object
-
- us.codecraft.webmagic.thread.CountableThreadPool
-
public class CountableThreadPool extends java.lang.Object
Thread pool for workers.
UseExecutorService
as inner implement.
New feature:
1. Block when thread pool is full to avoid poll many urls without process.
2. Count of thread alive for monitor.- Since:
- 0.5.0
- Author:
- code4crafer@gmail.com
-
-
Constructor Summary
Constructors Constructor Description CountableThreadPool(int threadNum)
CountableThreadPool(int threadNum, java.util.concurrent.ExecutorService executorService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(java.lang.Runnable runnable)
int
getThreadAlive()
int
getThreadNum()
boolean
isShutdown()
void
setExecutorService(java.util.concurrent.ExecutorService executorService)
void
shutdown()
-
-
-
Method Detail
-
setExecutorService
public void setExecutorService(java.util.concurrent.ExecutorService executorService)
-
getThreadAlive
public int getThreadAlive()
-
getThreadNum
public int getThreadNum()
-
execute
public void execute(java.lang.Runnable runnable)
-
isShutdown
public boolean isShutdown()
-
shutdown
public void shutdown()
-
-