Java Thread Local related question

Discussions

General J2EE: Java Thread Local related question

  1. Java Thread Local related question (1 messages)

    Hi guys, How does the thread local works in web applications. Does each http request has a unique thread local reference ?? Let me elobarate my question a bit. I have a logger instance that i need instantiate depending on some conditions. So each time a http request hits my web server, I create a logger instance and put in the thread local, when i am done processing the request, in the filter before dispatching the request, i remove the thread local reference. But my question is, Since the web server process the http requests depending on its own thread management. Is there any chance that two http requests getting the same thread local reference. If i am not clear or have confused you, Please let me know i will detail the problem with some code. Thanx and Regards KR Kumar
  2. Most of the webservers use 'thread per request pattern', that means each http request is assigned to a different thread always. So there is no chance that two different HTTP request would end up using same getting the same ThreadLocal reference. It might help though to provide information about which webserver you are using. HTH