Asynchronous Processing = Spanning Threads = Valid?

Posted by jens on Stack Overflow See other posts from Stack Overflow or by jens
Published on 2010-05-11T18:22:43Z Indexed on 2010/05/12 0:54 UTC
Read the original article Hit count: 484

Filed under:
|

Hello Experts,

am I allowed (without any sideeffects) to create and start a new Thread() from within a doGet() Method of a servlet? Or does this somehow leak ressources?

Is it valid to also pass the "Session" Object into the Thread to later save the result of my asynchronous processing (I will synchronized correctly) in the session? Or will this leak ressources when using the session "in indepedant threads"?

=> What would happen if the session meanwhile would be expired by the webcontainer as it has timedout and I will access it from my thread? Or would could this also lead to the sideffect, that storing the session in the thread will prevent the webcontainer from expiring the session at all (and therefore finally leak ressources as the sessions do not get cleared up)?

(I know there are other Solutions, like working with DB-(Job)Records, JMS or Servlets 3.0) but I need so solve the problem as described by spanning a new Thread within doGet.)

Thank you very much!! Jens

© Stack Overflow or respective owner

Related posts about java

Related posts about servlets