tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Meyer <>
Subject Re: multiple t hreads
Date Mon, 17 Jul 2006 14:09:13 GMT

> how to start multiple threads of a single instance of a tomcat
> where each thread runs a different it possible
> with tomcat if so how

This can be done in the normal way.  Your servlet can start
separate threads, each of which runs somewhat independently.

However, there is a problem with this if you are intending to run
a thread in the background while returning information to the
client in the primary thread.

When I tried to do that on older versions of Tomcat (4.x), all
output to the user was suspended until _all_ of the threads
completed.  So you can't use this technique to run a batch job on
behalf of the user.  In fact, running a long batch job will time
out the webserver and abort the job.

What I did to overcome that was to spawn a new Java virtual
machine that ran apart from Tomcat.  To do this, I used an open
source routine by Marty Hall.  You can exec "java classname" or
exec a shell script or batch file that starts the JVM.



Alan Meyer

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message