On Tuesday 18 January 2011 1:41:27 pm Benson Margulies wrote:
> On Tue, Jan 18, 2011 at 11:52 AM, Daniel Kulp <[email protected]> wrote:
> > There is one more case.   With JAX-WS, the endpoint can have an Excecutor
> > set on it.  In that case, all the processing we do will be on the main
> > thread, but right before the invoke call, a runnable will be put on the
> > give executor which will likely make the invoke on a background thread.
> >  The main thread will wait for a response though.
> > 
> > Kind of an obscure case though. The TCK is likely the only one that
> > actually uses that functionality.   :-)
> > 
> > Dan
> 
> I have this sinking feeling that I've asked you this before, but ...
> is there some reason why this is a bad way to accomplish handling
> multiple requests in parallel?

Well, it doesn't  really accomplish anything for your most common transport: 
http.   With servlets (forget 3.0 for a moment) the calling thread has to be 
the one that also handles the response.  Thus, if you use an executor, the 
calling HTTP thread has to sit there and wait for the response.   Thus, with 
the executor, you end  up using 2 threads, not just one. 

Also, by flipping threads, there are other potential issues such as the Spring 
security context not existing (or being incorrect) or the spring/jms 
transaction being incorrect and such.

The one case where the executor is actually useful is to do the exact reverse 
of what you want:  single thread the impl.   By using a synchronous executor, 
you can make sure the calls into the impl are done one at a time.   


-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog

Reply via email to