Pregunta

I think, I don't really get concept of asynchronous Servlet. First of all, why we had to mark asyncSupport = true? Whether it true/false I can created ThreadPool and add task to it, to execute that task asynchronous, right? So what is the difference, what I cannot achieve without asyncSupport? Any example appreciated.

¿Fue útil?

Solución

AsyncContext is convenient when you do need to keep the connection until you have some data to return after some time in the future without blocking the thread.

In one project I had a remote client which connected to the server and waited (long timeout) for the command from server. So called long-polling approach. Once server has some data to send it takes the AsyncContext and commits the response. It's very convenient as otherwise we would need to block a thread.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top