The sessions essentially just a sort of Map. Access to it may be threadsafe, but the stuff thats in it is another matter entirely. Multiple requests associated with the same session will execute simultaneously.
If you have >1 threads playing with the same unsafe object (which you just happened to pull out of the session) then of course you will need to synchronise their access to it externally. ie: Garthop unsafeObject = (Garthop)session.getAttribute(THE_GARTHOP); synchronized(unsafeObject) { garthop.nargle(); } -----Original Message----- From: Joe Hertz [mailto:[EMAIL PROTECTED] Sent: Thursday, 18 December 2003 15:56 To: 'Struts Users Mailing List' Subject: Are httpSessions thread safe? Not sure how OT this question is. My current plan (unless this is bad for some reason, but if so, Ted H should change his example app :-) is to stash the hibernate Session for a user into his httpSession, and reuse it on each request. A Hibernate Session instance isn't threadsafe. I imagine if two really quick http requests got generated out of the same browser, all hell could break out. I guess I want to know if mortals like me need to worry about this. Does Struts (or the Servlet container FAIK) prevent this from occuring, or do I need to ensure this doesn't happen? If so, how? With a token or is there a better strategy? TIA -Joe --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]