com.github.axet.wget
Class LimitThreadPool

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by com.github.axet.wget.LimitThreadPool
All Implemented Interfaces:
Executor, ExecutorService

public class LimitThreadPool
extends ThreadPoolExecutor


Nested Class Summary
protected static class LimitThreadPool.BlockUntilFree
           
protected static class LimitThreadPool.SafetyCheck
           
 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
 
Constructor Summary
LimitThreadPool(int maxThreadCount)
           
 
Method Summary
 boolean active()
          downloader working if here any getTasks() > 0
protected  void afterExecute(Runnable r, Throwable t)
           
protected  void beforeExecute(Thread t, Runnable r)
           
 void blockExecute(Runnable command)
           
 void execute(Runnable command)
          You should not call this method on this Limited Version Thread Pool.
 void waitUntilNextTaskEnds()
          Wait until current task ends.
 void waitUntilTermination()
          Wait until thread pool execute its last task.
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, 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, terminated
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LimitThreadPool

public LimitThreadPool(int maxThreadCount)
Method Detail

beforeExecute

protected void beforeExecute(Thread t,
                             Runnable r)
Overrides:
beforeExecute in class ThreadPoolExecutor

afterExecute

protected void afterExecute(Runnable r,
                            Throwable t)
Overrides:
afterExecute in class ThreadPoolExecutor

active

public boolean active()
downloader working if here any getTasks() > 0


waitUntilNextTaskEnds

public void waitUntilNextTaskEnds()
                           throws InterruptedException
Wait until current task ends. if here is no tasks exit immidiatly.

Throws:
InterruptedException

waitUntilTermination

public void waitUntilTermination()
                          throws InterruptedException
Wait until thread pool execute its last task. Waits forever unti end.

Throws:
InterruptedException

execute

public void execute(Runnable command)
You should not call this method on this Limited Version Thread Pool. Use blockExecute() instead.

Specified by:
execute in interface Executor
Overrides:
execute in class ThreadPoolExecutor

blockExecute

public void blockExecute(Runnable command)
                  throws InterruptedException
Throws:
InterruptedException


Copyright © 2012. All Rights Reserved.