Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Async servlets and thread-safety

Hi,

On Fri, Jan 25, 2013 at 4:20 PM, Nils Kilden-Pedersen <nilskp@xxxxxxxxx> wrote:
> I have some questions on async servlets and I figured this forum would be as
> good as any.
>
> I've done servlet programming for quite a few years, and I've always dealt
> with the request/response cycle as single-threaded. However, does this
> assumption still hold? Or rather, if building servlet components, do they
> now need to be built in a thread-safe manner, because the request/response
> cycle no longer is guaranteed to execute on a single thread, because of the
> introduction of async execution?

This is in general correct.

A lot of the details depend on your exact code, and the async servlet
API is easy to get not exactly right.

I recommend you try to *not* write your applications using directly
the async servlet APIs if it's possible.
Look for frameworks like CometD (http://cometd.org) if you need web
messaging, look at various utility classes that Jetty provides (like
DoSFilter, QoSFilter, etc.).

> I haven't been able to find very much information on this subject, so any
> explanations or pointers would be much appreciated.

There are a number of tutorials online, Google is your friend here.

If you really need to write against the async servlet APIs, at the end
it's not that complex, but does require a bit of multi-thread
experience to avoid common mistakes.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top