thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Boisvert <a...@bizo.com>
Subject Re: TThreadPool (java) - increase threads?
Date Wed, 18 Aug 2010 12:00:36 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message