org.kuali.common.threads
Class ThreadHandlerFactory
java.lang.Object
org.kuali.common.threads.ThreadHandlerFactory
public class ThreadHandlerFactory
- extends Object
Produce ThreadHandlers that create and control execution of threads for iterating over List objects
|
Method Summary |
protected int[] |
getDivideEvenly(int numerator,
int denominator)
Return an array of int's that represents as even of a split as possible
For example: passing in 100,7 returns 15, 15, 14, 14, 14, 14, 14 |
protected
|
getThread(Runnable runnable,
int id,
ThreadGroup group,
Thread.UncaughtExceptionHandler handler)
Construct a Thread from the information provided |
protected int |
getThreadCount(int max,
int min,
int elements,
int divisor)
Get the number of threads to use. |
|
getThreadHandler(ThreadHandlerContext<T> context)
Given some context, produce a ThreadHandler for iterating over the list of elements provided in the context |
protected
|
getThreads(ThreadHandler<T> thandler,
List<T> list,
ElementHandler<T> ehandler,
int[] lengths)
Generate threads where each thread iterates over a portion of the list |
protected void |
validate(int max,
int min,
int elements,
int divisor)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ThreadHandlerFactory
public ThreadHandlerFactory()
getDivideEvenly
protected int[] getDivideEvenly(int numerator,
int denominator)
- Return an array of int's that represents as even of a split as possible
For example: passing in 100,7 returns 15, 15, 14, 14, 14, 14, 14
- Parameters:
numerator - denominator -
- Returns:
getThreadHandler
public <T> ThreadHandler<T> getThreadHandler(ThreadHandlerContext<T> context)
- Given some context, produce a ThreadHandler for iterating over the list of elements provided in the context
- Type Parameters:
T - - Parameters:
context -
- Returns:
getThreads
protected <T> Thread[] getThreads(ThreadHandler<T> thandler,
List<T> list,
ElementHandler<T> ehandler,
int[] lengths)
- Generate threads where each thread iterates over a portion of the list
- Type Parameters:
T - - Parameters:
threadHandler - list - elementHandler -
- Returns:
getThread
protected <T> Thread getThread(Runnable runnable,
int id,
ThreadGroup group,
Thread.UncaughtExceptionHandler handler)
- Construct a Thread from the information provided
- Type Parameters:
T - - Parameters:
runnable - id - group - handler -
- Returns:
getThreadCount
protected int getThreadCount(int max,
int min,
int elements,
int divisor)
- Get the number of threads to use. The number returned here will never be greater than max. It may be less than
min, but only in the case where elements is also less than min.
- Parameters:
max - min - elements - divisor -
- Returns:
validate
protected void validate(int max,
int min,
int elements,
int divisor)
Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.