Jim
Jim

Reputation: 19582

Thread reuse in Tomcat

Tomcat uses a thread pool and reuses threads I was wondering does it reuse threads across sessions or across requests?

Upvotes: 2

Views: 2439

Answers (2)

helios
helios

Reputation: 13841

Across request and sessions. Everything. If a thread couldn't be used by different sessions your server would collapse in a couple of seconds/minutes, when 300 users get their session id's (and respective threads be reserved) and user number 301 want to access.

Think of it as:

server waiting for request:
on request:
  obtain free thread from pool
  put that thread to process request (by example: doGet(Req, Resp))
  when finished return thread to pool

Every request to server (from whoever is) is processed by the first free thread in the pool.

Upvotes: 4

Amit Deshpande
Amit Deshpande

Reputation: 19185

Apache Tomcat Configuration Reference states below.

The Executor represents a thread pool that can be shared between components in Tomcat. Historically there has been a thread pool per connector created but this allows you to share a thread pool, between (primarly) connector but also other components when those get configured to support executors

Upvotes: 1

Related Questions