So what makes these apps special? What makes them different from other things that might at first glance appear similar? Fundamentally, they all use long-lived HTTP connections to reduce the latency with which messages are passed to the server. In essence, they do not poll the server occasionally. Instead the server has an open line of communication with which it can push data to the client.
The architecture relies on a view of data which is event driven on both sides of the HTTP connection"
The above style of communication is now widely used in Flex, but it is not "long-lived Http". So is this style of communication possible in Http? Sure with Comet style requests we can have long lived requests so that ajax clients, apart form polling, can also enjoy the "server-push" data. But what about the effects of this long lived Http connections? How does the server (servlet container) handle these requests?It is considered that "thread-per-request" is a better model than "thread-per-connection", when serving thousands of clients simulataneously (not for serving max requests per second). But with long lived connections, the "thread-per-request" model doesnt hold good. Consider a thousand ajax clients haing long lived connections toa server. With "thread-per-request" model, the server will run out of threads to process new requests. So a new approach is needed on the server side, if Comet style requests are to be supported scalably.
One of the new approaches is "Continuations". If continuations is a new term for any, whats the best site to check for its meaning other than wikipedia? This link gives an excellent introduction to continuations (atleast to me, i didnt find any page which describes the concept in such accurate simple words) .
Now the greedy question is "Can i use it in Java? Can i use it to develop web applications in Java?". Yes! Jetty supports continuations on the server side. For more information, visit their wiki site.
The basic idea is to have long lived connections, but to used threads effeciently. Continuations seem to support that, they only allocate threads to these long-lived connections when an event occurs, threads don't waste time waiting for blocking IO etc.
I also found an article on continuations in Rife and scalability with Terracota.
Also Scala, has support for continuations. But more on that in an other post.