servlet is not thread safe

In tomcat container, the servlet singleton default; if the interface is implemented ISingleThreadModule marker to create multiple instances (up to 20) for a plurality of requests, in order to achieve security thread, may be:

1. Using a local variable instead of instance variables

2. Using the synchronized keyword

 

Summary description of the static variables, instance variables, local variables, using a range of three or greater, the more the life cycle is not thread-safe

Guess you like

Origin www.cnblogs.com/hzq3554055/p/12004630.html