On Wed, Aug 18, 2010 at 1:52 AM, Phillip B Oldham
<[email protected]>wrote:
> It seems, looking at some debugging output on my server, that the
> TThreadPool class in Java only creates 4 threads by default. How can I
> increase that limit?
>
By default you get a CachedThreadPool returned by
Executors.newCachedThreadPool(). This thread pool that creates new threads
as needed, but will reuse previously constructed threads when they are
available.
If you want to get a ThreadPool with fixed mininum and maximum number of
threads, you can use one of the TThreadPoolServer constructors that takes an
Options instance:
public TThreadPoolServer(TProcessor processor,
TServerTransport serverTransport,
TTransportFactory inputTransportFactory,
TTransportFactory outputTransportFactory,
TProtocolFactory inputProtocolFactory,
TProtocolFactory outputProtocolFactory,
Options options) {
...
}
The Options class is defined as a static inner class of TThreadPoolServer:
// Customizable server options
public static class Options {
public int minWorkerThreads = 5;
public int maxWorkerThreads = Integer.MAX_VALUE;
public int stopTimeoutVal = 60;
public TimeUnit stopTimeoutUnit = TimeUnit.SECONDS;
}
Hope this helps,
alex