• Post Reply Bookmark Topic Watch Topic
  • New Topic

Timer  RSS feed

 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I want to dispatch a process, and later discard it if it could not complete process within the specified length of time. Can I use a daemon thread to count the time period? Or is there a better standard way to do it?

I had a looked at the util.Timer class. But it doesnt help.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you could use a daemon thread for this. You also could use a Timer, and you can even create the Timer to use a daemon thread. For example if you're using Runtime's exec() method to start a Process, it might look like this:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!