This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Threads and Synchronization and the fly likes Threads getting timeout with out finishing tasks(using ExecutorService ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Threads getting timeout with out finishing tasks(using ExecutorService )" Watch "Threads getting timeout with out finishing tasks(using ExecutorService )" New topic
Author

Threads getting timeout with out finishing tasks(using ExecutorService )

Ravi Tej Pidatala
Greenhorn

Joined: Jan 29, 2012
Posts: 14
Hello ,



I am trying to run a multi threaded application where each thread runs a query (the queries are in a list ) and writes the resultSet to a new file . The task may sometime take 5 hrs to execute i.e. retriving and writing the resultset . When ever I run this application , I see that , the tasks are not getting completed (I mean all the data is not being written ) . I suspect that the threads are getting timedOut while running the database query so application is exiting .

Can any one tell how to increase the timeOut of the threads in executorService , so that I can set the time to 8 hrs and the application would not exit before tasks get completed ?

thanks in advance .
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4180
    
  21

Threads don't have a timeout associated with them. Neither do the normal methods used for executing tasks in an executor service. I would think the timeout is either Coming from the JDBC driver/ database or from the network appliance used to connect to the server. You probably don't want to keep an open network connection to the server the entire 8 hours, I wouldn't think. What I would do is have your application trigger the long task and tell the server how to contact the application when it is done (like have a socket & IP address the app can listen on). Or maybe have the app start the server working and then check every so often (10 minutes, half an hour,...) to see if the server is done and get the results if it is.


Steve
Ravi Tej Pidatala
Greenhorn

Joined: Jan 29, 2012
Posts: 14
Thanks Steve . It was database exception only . I could get stack trace by using try catch .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads getting timeout with out finishing tasks(using ExecutorService )