aspose file tools*
The moose likes Threads and Synchronization and the fly likes thread started a process, now what? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "thread started a process, now what?" Watch "thread started a process, now what?" New topic
Author

thread started a process, now what?

Alex Kravets
Ranch Hand

Joined: Jan 24, 2001
Posts: 476
Hi,

I have a class that starts up a thread and inside thread's run() method is called. Rougly it goes like this:



So here thread starts a timer and runs until either longTask() returns something or timer expires.

I have two questions:

1.Is while loop in run() enough to kill a thread?
2.longTask() is an abstract method that must be implemented by extending class, so if there is a long process in the implementation of longTask(), when this thread dies will/should whatever is going on in longTask() die as well?

thanks,
Alex
[ July 31, 2006: Message edited by: Alex Kravets ]

All right brain, you don't like me and I don't like you, but let's just do this one thing so I can get back to killing you with beer.<br /> <br />- Homer Simpson
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Here's how I approached the same requirement ... if I got it right

I don't have my actual code in hand, but I think join(nnn) just returns after the time and doesn't throw anything. I did this because I couldn't find any way to kill the long running task or make it time out. If it takes more time than allowed, I exception out but the task goes on to completion and the result is thrown away.

Does that solve the right problem?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: thread started a process, now what?