|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.httplite.server.ThreadPool
public class ThreadPool
This class implements a simple thread pool for servicing HTTP connections. The thread pool does not create any threads initially, but waits for connections to be added to create threads. As connections are added, threads are only created if they are needed up until the thread limit. If threads are inactive for a period of time, then the threads terminate; the default is 60000 milliseconds.
Field Summary | |
---|---|
static int |
DEFAULT_THREAD_TIMEOUT
Default thread timeout |
Constructor Summary | |
---|---|
ThreadPool(int threadLimit,
int threadTimeout,
Logger logger)
Constructs a thread pool with the specified thread limit and inactivity timeout. |
|
ThreadPool(int threadLimit,
Logger logger)
Constructs a thread pool with the specified thread limit and with the default inactivity timeout. |
Method Summary | |
---|---|
void |
addConnection(Connection connection)
This method adds an HTTP connection to the thread pool for servicing. |
int |
getState()
This method returns the current state of the thread pool, which is one of the following values: ThreadPool.INACTIVE_STATE - the thread pool is currently not active. |
void |
start()
Starts the thread pool if it is not already active, allowing it to service connections. |
void |
stop()
This method stops the thread pool if it is currently active. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_THREAD_TIMEOUT
Constructor Detail |
---|
public ThreadPool(int threadLimit, Logger logger)
threadLimit
- The maximum number of threads in the pool.logger
- Logger instance.public ThreadPool(int threadLimit, int threadTimeout, Logger logger)
threadLimit
- The maximum number of threads in the pool.threadTimeout
- The inactivity timeout for threads in milliseconds.logger
- Logger instance.Method Detail |
---|
public int getState()
public void start()
java.lang.IllegalStateException
- If the thread pool is in the
ThreadPool.STOPPING_STATE state.public void stop() throws java.lang.InterruptedException
java.lang.InterruptedException
- If the calling thread is interrupted.public void addConnection(Connection connection)
connection
-
java.lang.IllegalStateException
- If the thread pool is not in the
ThreadPool.ACTIVE_STATE state.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |