Yes.  As a non-static instance variable, each thread would have it's own
reference and be able to set and maintain it's value separately from any
other thread.

Mark

-----Original Message-----
From: Esbrook, Scott [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 03, 2002 7:45 AM

Quick Struts/servlet threading question: If many classes extended the
following 'AbstractAction' class (eg, 'ConcreteAction'), would use of the
'testString' member variable be threadsafe?

public abstract class AbstractAction extends Action{
   protected String testString;
   public ActionForward perform(
      ActionMapping map,ActionForm form,HttpServletRequest
req,HttpServletResponse res){
      testString = req.getParameter("myParam");
      // other common processing....
      return process(map,form,req,res);
   }
   public abstract ActionForward process(
      ActionMapping map,ActionForm form,HttpServletRequest
req,HttpServletResponse res);
}
public class ConcreteAction extends AbstractAction{
   public ActionForward process(
      ActionMapping map,ActionForm form,HttpServletRequest
req,HttpServletResponse res){
      // do something with testString...
      // return an ActionForward object...
   }
}

I was strictly thinking of using the protected members on a per-request
basis, always initializing them in the AbstractAction's perform() method.
Furthermore, if use of testString is OK, wouldn't it be OK to have a member
vars of type HttpRequest, etc. and set it/them in AbstractAction's
perform(), thereby avoiding all the associated parameter passing? 

Using Struts 1.0.2 if that makes any difference.

Thanks,

Scott Esbrook
Software Developer
Compuware Corporation

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to