I know that Struts 2 Actions are thread safe. But what happens if those Action classes contains method calls to utility static methods? Will thread safety be compromised?
Take a utility method that will parse an uploaded excel file etc. If the method is to be declared static should it be synchronized?
Update:
I’m just reading the file, and the file is submitted to the action so in itself it should be thread safe… But Since the parsing is done in a utility method I’m having doubts whether synchronization is necessary or not. But apparently if you are accessing only method scope variables it should be thread safe. But does parameters like File fall under that category?
As per my understanding thread safety will not be compromised until unless you are playing around with share data between threads.you must take care of atomicity, visibility, etc.
IF there are any method level variables are replicated in each thread execution stack and only race conditions can arises if there is any shared data and for such we need to take care of.
Though The stack is local to the current thread, but there can be references to shared objects on that stack.