se.unlogic.standardutils.threads
Class ThreadPoolTaskGroupHandler<T extends TaskGroup>

java.lang.Object
  extended by se.unlogic.standardutils.threads.ThreadPoolTaskGroupHandler<T>
All Implemented Interfaces:
Runnable, TaskGroupHandler<T,SimpleExecutionController<T>>

public class ThreadPoolTaskGroupHandler<T extends TaskGroup>
extends Object
implements TaskGroupHandler<T,SimpleExecutionController<T>>, Runnable


Field Summary
protected  Status status
           
protected  Condition taskGroupAddCondition
           
protected  ReentrantLock taskGroupAddLock
           
protected  int taskGroupIndex
           
protected  CopyOnWriteArrayList<SimpleExecutionController<T>> taskGroupList
           
protected  Condition taskGroupRemoveCondition
           
protected  ReentrantLock taskGroupRemoveLock
           
protected  ArrayList<Thread> threads
           
 
Constructor Summary
ThreadPoolTaskGroupHandler(int poolSize, boolean daemon)
           
 
Method Summary
 void abortAllTaskGroups()
           
 void awaitTermination()
           
 void awaitTermination(long timeout)
           
 SimpleExecutionController<T> execute(T taskGroup)
           
protected  int getIndex()
           
 int getLiveThreads()
           
 Status getStatus()
           
 int getTaskGroupCount()
           
 List<SimpleExecutionController<T>> getTaskGroups()
           
 int getTotalTaskCount()
           
 boolean isEmpty()
           
 void run()
           
 void shutdown()
           
 void shutdownNow()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

taskGroupRemoveLock

protected final ReentrantLock taskGroupRemoveLock

taskGroupRemoveCondition

protected final Condition taskGroupRemoveCondition

taskGroupAddLock

protected final ReentrantLock taskGroupAddLock

taskGroupAddCondition

protected final Condition taskGroupAddCondition

taskGroupList

protected final CopyOnWriteArrayList<SimpleExecutionController<T extends TaskGroup>> taskGroupList

taskGroupIndex

protected int taskGroupIndex

status

protected Status status

threads

protected final ArrayList<Thread> threads
Constructor Detail

ThreadPoolTaskGroupHandler

public ThreadPoolTaskGroupHandler(int poolSize,
                                  boolean daemon)
Method Detail

run

public void run()
Specified by:
run in interface Runnable

isEmpty

public boolean isEmpty()

getLiveThreads

public int getLiveThreads()

getIndex

protected int getIndex()

abortAllTaskGroups

public void abortAllTaskGroups()
Specified by:
abortAllTaskGroups in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>

execute

public SimpleExecutionController<T> execute(T taskGroup)
                                                       throws RejectedExecutionException
Specified by:
execute in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>
Throws:
RejectedExecutionException

getTaskGroupCount

public int getTaskGroupCount()
Specified by:
getTaskGroupCount in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>

getTaskGroups

public List<SimpleExecutionController<T>> getTaskGroups()
Specified by:
getTaskGroups in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>

getTotalTaskCount

public int getTotalTaskCount()
Specified by:
getTotalTaskCount in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>

getStatus

public Status getStatus()
Specified by:
getStatus in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>

awaitTermination

public void awaitTermination()
                      throws InterruptedException
Specified by:
awaitTermination in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>
Throws:
InterruptedException

awaitTermination

public void awaitTermination(long timeout)
                      throws InterruptedException
Specified by:
awaitTermination in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>
Throws:
InterruptedException

shutdown

public void shutdown()
Specified by:
shutdown in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>

shutdownNow

public void shutdownNow()
Specified by:
shutdownNow in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>


Copyright © 2011. All Rights Reserved.