> From: Tim Funk <funkman () joedog ! org>
> Subject: Re: [Q] Is it safe to create threads in Tomcat web-apps?

> You can create threads all day in tomcat, but here are the importnatn things
> to consider:

> - WHY! Are threads really the correct solution?
> - And last but not least: WHY! Are threads really the correct solution?

I'm getting the impression that you think multiple threads are never
the right answer.  :) That's not necessarily true.

Suppose that your response to a request contains three steps which are
independant of one another; in order to deliver a faster response
time, you'd like to execute them concurrently.

If these three steps are CPU-bound, then the amount of benefit really
depends on the machine; you need multiple CPUs so that the scheduler
can run the different threads on different CPUs.  With a single CPU,
you're not likely to see much benefit.

However, if the three steps are IO-bound, using multiple threads to
run them concurrently can lead to a big improvement.  Most of the time
spent doing IO is spent waiting.  (Particularly if the IO is network
IO, a "sub-request" to a remote site, for example).  If the idle times
occur concurrently instead of serially, you'll certainly do better.

-- 
Steve

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to