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

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

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


Field Summary
protected  Status status
           
protected  java.util.concurrent.locks.Condition taskGroupAddCondition
           
protected  java.util.concurrent.locks.ReentrantLock taskGroupAddLock
           
protected  int taskGroupIndex
           
protected  java.util.concurrent.CopyOnWriteArrayList<SimpleExecutionController<T>> taskGroupList
           
protected  java.util.concurrent.locks.Condition taskGroupRemoveCondition
           
protected  java.util.concurrent.locks.ReentrantLock taskGroupRemoveLock
           
protected  java.util.ArrayList<java.lang.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()
           
 java.util.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 java.util.concurrent.locks.ReentrantLock taskGroupRemoveLock

taskGroupRemoveCondition

protected final java.util.concurrent.locks.Condition taskGroupRemoveCondition

taskGroupAddLock

protected final java.util.concurrent.locks.ReentrantLock taskGroupAddLock

taskGroupAddCondition

protected final java.util.concurrent.locks.Condition taskGroupAddCondition

taskGroupList

protected final java.util.concurrent.CopyOnWriteArrayList<SimpleExecutionController<T extends TaskGroup>> taskGroupList

taskGroupIndex

protected int taskGroupIndex

status

protected Status status

threads

protected final java.util.ArrayList<java.lang.Thread> threads
Constructor Detail

ThreadPoolTaskGroupHandler

public ThreadPoolTaskGroupHandler(int poolSize,
                                  boolean daemon)
Method Detail

run

public void run()
Specified by:
run in interface java.lang.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 java.util.concurrent.RejectedExecutionException
Specified by:
execute in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>
Throws:
java.util.concurrent.RejectedExecutionException

getTaskGroupCount

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

getTaskGroups

public java.util.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 java.lang.InterruptedException
Specified by:
awaitTermination in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>
Throws:
java.lang.InterruptedException

awaitTermination

public void awaitTermination(long timeout)
                      throws java.lang.InterruptedException
Specified by:
awaitTermination in interface TaskGroupHandler<T extends TaskGroup,SimpleExecutionController<T extends TaskGroup>>
Throws:
java.lang.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.