• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Thread - destroy()

 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What other method is appropriate to use instead of thread.destroy() so that a thread can die gracefully.
Roopa.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if I'm very right but I think that thread.stop make the thread to die too. Because when thread.stop is called the thread dies and cannever resume again. please pardon me if I'm wrong.
 
Roopa Bagur
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thread.stop,thread.resume & thread.suspend are deprecated methods..

Originally posted by Ify Innoma:
I don't know if I'm very right but I think that thread.stop make the thread to die too. Because when thread.stop is called the thread dies and cannever resume again. please pardon me if I'm wrong.


 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the best way to do this is to make an loop inside the run method and test a condition before every iteration. When you want the thread to die, just change the loop condition. This way is very clean and does not need stop or other deprecated methods to be used...
Val
[This message has been edited by Valentin Crettaz (edited September 23, 2001).]
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public void destroy()
Destroys this thread, without any cleanup. Any monitors it has locked remain locked. (This method is not implemented.)
Do what Val suggests.
 
reply
    Bookmark Topic Watch Topic
  • New Topic