Java Mailing List Archive

http://www.junlu.com/

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

Threads in Tomcat

kwirirai

2004-02-15

Replies:

Thanks to All, I have done all the stuff to make my web app thread safe,
It seems its fine for the moment.Except for a few more things.
It seems threading is realy complex. I am forking out a new thread in my
Handle request method and this is making the other request to wait for
the other thread to complete.

Actualy what is happening is this I have this code , I am using Velocity

public Template handleRequest( HttpServletRequest request,
  HttpServletResponse response, Context context )
  {    

   .......
    .......
     someCode1;
     gmh=new MyThread();
     new Thread(gmh).start();
     someCode2;
}


when two clients make a request ,suppose client1 makes a request then
manages to start the thread first then client2 makes a request while
client1 thread has already started running ,client2 will somehow be
forced to wait on someCode1 until client1 thread has finished .Can you
imagine if client1 takes a very long time to finish,that means client2
will also take a very long time

I do not think it should do this
I was thinking of using a thread pool, now I need some example code to
use a thread pool havent got any idea were to start, just some pointers
to help me ,dont want to give you too much trouble :-)

Thanks in advance


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.