1

When am trying to stop a running thread, most of the methods to stop the thread are being shown "deprecated" in eclipse. I am using either of the methods stop(),destroy(),suspend(). Is there a new method for stopping a thread?

Thanks.

Trooper
  • 145
  • 3
  • 15
  • Can you share the sample code that you are trying? use a `flag` as boolean to come out of `run` method. If run method is finished then thread is automatically closed. Rest depends on your code. – Braj Jun 23 '14 at 19:13
  • Because these methods are deprecated! – Am_I_Helpful Jun 23 '14 at 19:14
  • http://stackoverflow.com/q/16504140/1927832 – Suresh Atta Jun 23 '14 at 19:14
  • It is deprecated because it was bad. IIRC the new recommendation is to do periodic polling and have the thread stop itself by cleaning up and then returning from the run method. – Colin D Jun 23 '14 at 19:15
  • @ColinD---Well the question which you people have referred has only subpart of answer.Kindly open the question to be answered,else it will be considered monopoly of `higher rated professionals` on Stack Overflow! – Am_I_Helpful Jun 23 '14 at 19:17
  • @shekharsuman, I do not agree with you. I believe that everything that the OP may want to know is in the other question. – Mansueli Jun 23 '14 at 19:21
  • @shekharsuman I clearly think it is a duplicate of the one it is marked a duplicate as. The first answer looks like it provides a reason for deprecation and a solution for 'stopping'. If you disagree, the question linked by suresh, would be another likely candidate for being a duplicate. Stackoverflow has no need for duplicates, why would we ever re-open a question just for the sake of fake internet points? We are simply a site about providing answers for questions, re-answering questions just clutters the site. – Colin D Jun 23 '14 at 19:22

0 Answers0