Hello Guys,
I am using the threadPoolExecutor class from the
java api to handle all my threads. At the moment i have 5 threads that can exist in the
thread pool. My threads are all doing the same task. They are doing a requests to the database and they wait for a reply. Some times the database does not reply for some time. This means these threads get stuck in the thread pool waiting.
I was wondering was there any way to set a time out on threads in the thread pool. so if a thread is running for more than half an hour then the thread pool will kill it and process the next thread in the queue. I do not
At the moment the threads inside the thread pool have their own timer task that writes to a log saying the thread is taking more than 30 minutes. I am trying to think of a way of killing off threads that take this long.
java.util.concurrent.ThreadPoolExecutor
http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html
You are probably thinking why do you not look at the database side. I want to implement this timeout as a precaution if the database does not reply.
thanks for you time.