i would like to check what it means to have a synchronized instance method in a Struts 1 Action class?
Something like
publi开发者_如何学JAVAc synchronized String checkAction(){ ... }
It means the checkAction method is going to be synchronized by the enclosing Object's intrinsic lock (The Action class Object's lock). So only one thread at a time will be able to access the checkAction method.
In Struts 1 the Action class is not thread safe. So multiple threads (e.g. servicing multiple requests) will access the same instance of the Action class. Does the method need to be synchronized? I'm not sure - only you can tell by what's happening in the method. So long as it isn't accessing instance variables of the Action class or doing something which can only be done by a single thread at a time, then synchronization is probably not necessary.
精彩评论