I'm writing a Tomcat application which need to maintain some internal states across different requests, so I need share something between different threads created by Tomcat. My question is, if I write code like this, will Map
(which is static
to the class) be shared between threads created by Tomcat.
public class sessionManager extends HttpServlet {
private static HashMap<Integer, String> Map;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// logic
}
}
I guess what I really don't get is how does Tomcat create many threads from a single class.
Aucun commentaire:
Enregistrer un commentaire