The servlet itself does not have an issue with the so-called thread security, depending on how we use the servlet.
With the Tomcat Web container example, the servlet is loaded with a single instance in the container, and since the container is definitely running in multi-threaded mode, if the servlet uses static variables or instance variables, then it is certainly thread insecure. In order to ensure thread safety in high concurrency, the first prerequisite is stateless, in the actual development process, you can consider the use of local variables or threadlocal mechanism. The core mechanism for the spring framework to address thread safety issues is threadlocal. Threadlocal How to use this online information a lot, the use is relatively simple, it does not unfold. The official Oracle API instructions are attached below.
Threadlocal's API
Http://docs.oracle.com/javase/8/docs/api/java/lang/ThreadLocal.html