This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 3600
    
  14

Don't use a Thread. Instead, pass your task to an ExecutorService and supply a timeout.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making a Execution of a tasks take only constant Number of seconds
 
Similar Threads
Can you access methods of a thread's target?
reload context but the thread not stop
Daemon
Timer use?
Test your business service