Well Im not an 'expert' on threads so if anyone else reading this spots me making a mistake please shout! But heres the way I see the problem:
The issue is that the data that you have in your Servlet Context will be accessed from multiple threads at the same time. What this usually means is that your data object(s) needs to be accessed in a synchronized fashion. The easiest (best?) way to do that would be to synchronise your data objects getter and setters methods. class MyDataObjectThingy { private Stuff _stuff; public synchronized Stuff getStuff(); { return _stuff; } public synchronized void setStuff(Stuff stuff) { _stuff = stuff; } } An alternative approach is to synchronise from the code that accesses it - this could be in the controller objects you mentioned having in the session: (As each session has its own controller object working with data shared across all you cant just synchronise on the controller itself...) ie: MyDataObjectThingy thing = (MyDataObjectThingy )getServlet().get (etc...) synchronized(thing) { //read or write the data you need.... } But of course you have to do this _everywhere_ you access the shared objects - if not those places that dont aren't synchronized and can go in and use/change the data while another thread is halfway through reading or writing it leading to nasty bugs... -----Original Message----- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED]] Sent: Friday, November 22, 2002 14:13 To: Struts Users Mailing List Subject: RE: Thread-safety Hi, Yes. We use this code from within a controller stored in the user session. Now each user will get the controller from his session and call this code from within the controller but even then this might be a bit tricky. Our controller doesn't solve the problem. Isn't it ? Thanks, Mohan -----Original Message----- From: Andrew Hill [mailto:[EMAIL PROTECTED]] Sent: Friday, November 22, 2002 11:27 AM To: Struts Users Mailing List Subject: RE: Thread-safety It depends... -----Original Message----- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED]] Sent: Friday, November 22, 2002 13:20 To: Struts Users Mailing List Subject: Thread-safety Hi, getServlet().getServletContext() ); I have code like this in my reload action. Now this gets hold of the application context and refreshes it from the database. Since actions are reused we think there might be some problem with thread safety. Does it make sense to use code like this ? Thanks, Mohan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>