Tomcat's Org.apache.coyote.http11.Http11NioProtocol Connector is an asynchronous accept request that is implemented using Java NIO Connector
It does not need to establish a thread for each request, but instead uses a fixed accept thread to accept multiple requests and then queue up.
The idea is to use a fixed acceptthread to accept n requests, then queue the request, and finally use a fixed requestprocessingthread to process the business logic, and the processing of the business logic is actually synchronous
Http11nioprotocol support from Tomcat 6.x
Servlet 3.0 starts with the Tomcat 7.x, which makes the business process asynchronous, and the Spring 3.2 async becomes also based on the servlet 3.0来, for example
@ResponseBody @RequestMapping ("/{surl}") PublicDeferredresult<responseentity<string>>Redirect (@PathVariable String surl) {FinalDeferredresult<responseentity<string>> dr =NewDeferredresult<responseentity<string>>(Timeout_ms, responseentityresult.timeout); // ... Do something asynchronously, and finally set the result to Deferredresult NewThread (NewAsynctask (DR)). Start (); returnDr; } Private Static classAsynctaskImplementsRunnable {PrivateDeferredresult result; Privateasynctask (deferredresult result) { This. result =result; } @Override Public voidrun () {//Business Logic// ... //Set ResultsResult.setresult (Result); } }
This way Tomcat's requestprocessingthread can be freed to handle other requests, and servlet-2.5 you can only process the final result, return it, and not put it on another thread.
About Tomcat NIO Connector, servlet 3.0 async, Spring MVC async Relationship