I have a helper class that I pass values in and out of, including an ArrayList. This helper class is only written to using the Execute() method of an Action class. When I am done with this helper class in a particular request, it is saved back to the Session. Is the above thread safe? I know that ArrayLists by themselves are not, but I am only accessing it from a method - not as an instance variable. Does that matter? TIA, Paul
In this case, I think it could although the likelihood of it being a problem is probably very low. Since the object comes from the session collection, it becomes a "shared" resource in the session scope. Your local variable is really just a reference to the shared object. Is it likely that there will be multiple threads running for the same session, i.e., could the user, using the same session, submit multiple requests to the same action (this situation might occur is you use an automated testing tool that simulates concurrent access to your website)? Does your action spawn new threads that access the session and that particular helper object? If so, then you may need to synchronize. If not, then you'll probably be all right.