增加状态类
This commit is contained in:
parent
02ca1d4743
commit
e2566a1e39
@ -36,5 +36,48 @@ public class CachedThreadPoolUtil {
|
||||
executorService.execute(runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Status getStatus() {
|
||||
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executorService;
|
||||
return new Status(threadPoolExecutor.getQueue().size(),
|
||||
threadPoolExecutor.getActiveCount(),
|
||||
threadPoolExecutor.getCompletedTaskCount(),
|
||||
threadPoolExecutor.getTaskCount());
|
||||
}
|
||||
|
||||
public static class Status {
|
||||
private Integer queueSize;
|
||||
private Integer activeCount;
|
||||
private Long completedTaskCount;
|
||||
private Long totalTaskCount;
|
||||
|
||||
public Status(Integer queueSize, Integer activeCount, Long completedTaskCount, Long totalTaskCount) {
|
||||
this.queueSize = queueSize;
|
||||
this.activeCount = activeCount;
|
||||
this.completedTaskCount = completedTaskCount;
|
||||
this.totalTaskCount = totalTaskCount;
|
||||
}
|
||||
|
||||
public Integer getQueueSize() {
|
||||
return queueSize == null ? 0 : queueSize;
|
||||
}
|
||||
|
||||
public Integer getActiveCount() {
|
||||
return activeCount == null ? 0 : activeCount;
|
||||
}
|
||||
|
||||
public Long getCompletedTaskCount() {
|
||||
return completedTaskCount == null ? 0 : completedTaskCount;
|
||||
}
|
||||
|
||||
public Long getTotalTaskCount() {
|
||||
return totalTaskCount == null ? 0 : totalTaskCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user