silent_hacker
silent_hacker
2010-03-03 12:00

struts中Action定义全局友元变量的问题。

  • struts

public class SmsClientAction extends DispatchAction {

int temp;
public ActionForward getA(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
temp = 1;
System.out.println("A"+temp);
}

public ActionForward getB(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
temp = 2;
System.out.println("B"+temp);
}

}

}

如上所示。我做个线程里面循环 同时请求getA 和getB 会不会产生temp值乱了的问题? 如果int temp定义为private 呢?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答