Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Can servlets safely spawn threads?

Danny Ayers

2007-01-29

Replies:

Hi,

I would be grateful is someone could answer these questions:

* Can servlets safely spawn threads?
* If so, under what conditions?

I tried to find the answers searching the web, but found conflicting views.
So I thought it worth asking about a specific servlet container
implemention.

I'm trying to make a very simple asynchronous messaging system on top of
HTTP. What I have in mind requires that the servlet called would complete
the request-response in "reasonable" time, yet may initiate other processes
that are potentially long-running. The easiest approach would be to have the
servlet spawning another thread in which to run the other process, and
return a response to the client immediately. But is this possible without
running straight into concurrency breakage?

More background at :

http://dannyayers.com/2007/01/28/a-servlets-problem

Thanks,
Danny.

--

http://dannyayers.com
©2008 junlu.com - Jax Systems, LLC, U.S.A.