The servlets we have seen so far work in sync. That is, when a client connects to a servlet, the container assigns a server-side thread to the client and keeps it available until a response is generated and sent to the client.
If the client performs operations that require a long waiting time, the thread will remain busy for a long time, leaving a certain amount of memory space busy. If there are many connected users, the space will increase in proportion.
To solve these problems, there are asynchronous servlets. Asynchronous servlets allow dynamic thread management, allowing the container to fully utilize the available resources and avoid memory leaks.
There are several algorithms that calculate the available resources, allowing thread management that is best suited to cases.
The technology behind the asynchronous servlet is the same as that behind the WebSockets...