This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

thread started a process, now what?  RSS feed

 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!