ThreadLocal类可以避免多线程系统中的session的不安全问题.
public class MyServlet extends HttpServlet{
private ThreadLocal myhreadLocal=new ThreadLocal();
public void doGet(HttpServletRequest reqeust,HttpServletResponse response)throws Exception{
myThreadLocal.set(getSession());
play();
session.flush();
}
public void play(){
Session sess=(Session)myThreadLocal.get();
}