aspose file tools*
The moose likes Threads and Synchronization and the fly likes Making a Execution of a tasks take only constant Number of seconds Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Making a Execution of a tasks take only constant Number of seconds" Watch "Making a Execution of a tasks take only constant Number of seconds" New topic
Author

Making a Execution of a tasks take only constant Number of seconds

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

I have a Report Generation task , so for this i am starting a Thread .
The Report generation should take only 10000 Ms , or otherwise the Action should be terminated




I have coded this way , please tell me whether i can use join in this case ??

Thread thread = new Thread(this);
thread.setDaemon(true);
thread.start();


thread.join(waitSec );



Save India From Corruption - Anna Hazare.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  16

Don't use a Thread. Instead, pass your task to an ExecutorService and supply a timeout.
 
 
subject: Making a Execution of a tasks take only constant Number of seconds