Announcement Announcement Module
No announcement yet.
a single thread for lifetime of http request Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • a single thread for lifetime of http request

    I need to know if web or http request runs entirely in one thread. I understand that each request can, and usually is, a different thread but that is not what I'm asking.

    The preHandle method of my Handler Interceptor (extends org.springframework.web.servlet.handler.HandlerInt erceptorAdapter) saves some data like this:

    System.setProperty( "User_Name" + Thread.currentThread().getId(), userName);
    Then, the request's Controller (implements org.springframework.web.servlet.mvc.Controller) can retrieve the data when the Spring Dispatcher calls its handleRequest method:

    String userName = System.getProperty( "User_Name" + Thread.currentThread().getId() );
    Then I can remove the object in the postHandle method of the Interceptor.

    This will only work correctly if I'm guaranteed the same thread calls all the above methods. I have this code working in a Tomcat application server - but I'm the only one using it. I'm not sure if this will work in a busy production server. Plus, our production server is Oracle's IAS which may use threads differently.

    Does anyone know if I'm guaranteed that only one thread is used?