Q: Number of threads in thread pool for good perfomance I have a Executor thread pool with core size and maximum size both kept at 40 and each thread will use a HTTP connection from PoolingClientConnectionManager of Apache HTTP client with 40 connections per host route. I can see that if load is less the performance is also coming less...can you guys please help me out?

A: Use something like following:
ExecutorService service = Executors.newCachedThreadPool();

service.execute(someRunnable);

In this case, you needn't worry about the number of threads that are running.
The system will automatically scale the number of threads up and down for you.
Here is the documentation:

public static ExecutorService newCachedThreadPool()
Creates a thread pool that creates new threads as needed, but will
  reuse previously constructed threads when they are available. These
  pools will typically improve the performance of programs that execute
  many short-lived asynchronous tasks. Calls to execute will reuse
  previously constructed threads if available. If no existing thread is
  available, a new thread will be created and added to the pool. Threads
  that have not been used for sixty seconds are terminated and removed
  from the cache. Thus, a pool that remains idle for long enough will
  not consume any resources. Note that pools with similar properties but
  different details (for example, timeout parameters) may be created
  using ThreadPoolExecutor constructors.
Returns: the newly created thread pool

Hope it helps.

A: It all depends on how many cores you have in the host that's running your JVM and how much CPU you expect each thread to utilise.
Assuming an 8 core host where nothing else was running aside from your JVM, every task you execute is purely CPU bound, then you'd probably want to have a thread pool size of 7 (leaving one core free for JVM activities like garbage collection and other OS tasks).
However, systems are never that predictable, so it's probably better to do some profiling under expected loads and seeing what works best.
