Two Laptop Bag*
The moose likes Tomcat and the fly likes Max time of a thread in service method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Max time of a thread in service method" Watch "Max time of a thread in service method" New topic
Author

Max time of a thread in service method

Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
do anyone knows how long a thread can stay in service method? is there a max time in tomcat?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I think the problem is more frequently related to how long the browser will try to keep the connection open, not the limit in Tomcat.
However you might check the connectionTimeout in the server.xml Connector element.
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
[ March 13, 2004: Message edited by: William Brogden ]
Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
I'm facing a really bad problem! some times a thread spends too much time in a servie method (some times in a synchronized block) this blocks other threads and the hole thing goes down! any advise? The cause of threads spending lots of time in the service method is because they try to use a data base resource allready blocked by some user (outside the aplication), that forgets to release this resource!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
There have been a number of related discussions in the servlet forum about requests that take a long time. You could probably find them by searching.
Generally, the conclusion is that you should start a separate Thread in a Runnable object that tries to perform the time-consuming operation, while the request/response Thread writes something reasonable back to the client.
Naturally you keep a reference to the worker class in the session so that subsequent requests can look to see how well it is doing.
 
wood burning stoves
 
subject: Max time of a thread in service method
 
Similar Threads
service() method
HFSJ question: when service() method is called
init and service in same thread?
problem of thread safe
long running service call and tracking completion