thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip B Oldham <phillip.old...@gmail.com>
Subject Re: TThreadPool (java) - increase threads?
Date Wed, 18 Aug 2010 12:22:57 GMT
Executors.newCachedThreadPool sounds like its adequate for our needs.
Can I confirm this is used/available in 0.2.0?

On Wed, Aug 18, 2010 at 1:00 PM, Alex Boisvert <alex@bizo.com> wrote:
> On Wed, Aug 18, 2010 at 1:52 AM, Phillip B Oldham
> <phillip.oldham@gmail.com>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
>



-- 
Phillip B Oldham
phillip.oldham@gmail.com
+44 (0) 7525 01 09 01

Mime
View raw message