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

I'm wondering though. Even with async, your request is never handled by more than a single thread at a time, and one must presume that there are built-in synchronization points (locking or volatile) that ensures memory visibility, and if so, the servlet writer should not need to do anything differently.

On Mon, Jan 28, 2013 at 2:07 AM, Thomas Becker <tbecker@xxxxxxxxxxx> wrote:
Just to have this 100% clear, if you don't use the async servlet API and the like, you still can write your servlets the same way you always did.

If you directly use async features then what Simone wrote applies.

Am 1/25/13 8:36 PM, schrieb Simone Bordet:

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.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top