|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.util.ThreadPool
public class ThreadPool
ThreadPool manages threads which are created within the pool. The pool provides two main features: 1) threads created by the pool can be monitored for runtime exceptions. If an exception is not handled by the client code then the exception raises and reaches the ThreadPool which will handle it through a ThreadPoolMonitor. The client can provide its own monitor and handle the exception, or a default monitor will be used (@see ThreadPoolMonitor). The default monitor simply logs the exception. 2) checks if the number of concurrent threads (active) exceeds the threshold which is set at ThreadPool construction time. The ThreadPool does not enforce a restriction on the number of active threads. If the JVM cannot start a new thread the behavior is undefined. The ThreadPool logs the cases when the number of threads exceed the threshold. Then it tries to start the thread anyway.
Constructor Summary | |
---|---|
ThreadPool(int numberOfThreads)
Constructs a ThreadPool with a default monitor (@see ThreadPoolMonitor) and the given maximun number of concurrent threads |
|
ThreadPool(ThreadPoolMonitor monitor,
int numberOfThreads)
Constructs a ThreadPool with the given monitor and the given maximum number of concurrent threads |
Method Summary | |
---|---|
int |
getRunnableCount()
Returns the number of threads belonging to this pool that are currently running (still active) |
java.lang.Thread |
startThread(java.lang.Runnable task)
Start a new task in a separate thread which is monitored by the object monitor set in the constructor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ThreadPool(ThreadPoolMonitor monitor, int numberOfThreads)
monitor
- invoked in case of runtime exceptionnumberOfThreads
- maximum number of threadspublic ThreadPool(int numberOfThreads)
numberOfThreads
- maximum number of threadsMethod Detail |
---|
public int getRunnableCount()
public java.lang.Thread startThread(java.lang.Runnable task)
task
- is the Runnable object to be executed in a new thread
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |