File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Async Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Async Servlet" Watch "Async Servlet" New topic

Async Servlet

Eugene Rabii
Ranch Hand

Joined: Apr 24, 2009
Posts: 30
Hello dear ranchers hear is my question,

Trying to understand the Async Servlet for a few days now, no luck yet. May be you could help me. So, what literally happens when we call startAsync()? The request and the response gets somehow put on the server, while the "async" job gets done? For example:

AsyncContext context = request.startAsync();
context.start(new Runnable() {
public void run() {
try {
} catch (InterruptedException e) {

So, what this means is that the initial http Thread "releases" the request, some other worker thread picks it up and does the waiting (the async task) and the the http Thread builds the response.

I mean, from what I have read so far, the async support is for releasing some Thread, right? But if we release some Thread, the async job is done by some other Thread anyway. So, where do we win in the first place? Or may be some Threads are not that expensive as others?

P.S. There are no stupid questions, there are silly answers.

Thanks a lot!

I agree. Here's the link:
subject: Async Servlet
jQuery in Action, 3rd edition