java - how to make servlet instance variables thread safe? -


In the code below, I want to create get_data variable as a thread-safe. Please provide me some code.

  public class home_page_action HttpServlet {String get_data; Public Zero doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}}  

Firstly it is recommended, please do not create an example variable. Since only a copy of the servlet has been made, only the variables are within the thread-safe variable method.

Local variables are always a safe thread. However, keep in mind that the object indicates a local variable number, it can not happen. If this method was started within the law, and could never survive, then there will be no problem. On the other hand, a local variable, pointing to some shared object, can still cause problems. Just because you specify a shared object in a local context, this does not mean that the object is automatically secured with the thread.

Requests and feedback objects are definitely safe threads to use. They are designed for every request in your servlet, and thus for each thread executed in your overlays.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -