• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic