How I can replace deprecated method this.stop() in ThreadGroup Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How I can replace deprecated method this.stop() in ThreadHow do I efficiently iterate over each entry in a Java Map?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How can I create an executable JAR with dependencies using Maven?How can I convert a stack trace to a string?Why is Java Vector (and Stack) class considered obsolete or deprecated?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?How to declare or mark a Java method as deprecated?Replacement for deprecated sizeWithFont: in iOS 7?

How to react to hostile behavior from a senior developer?

Drawing without replacement: why is the order of draw irrelevant?

Performance gap between vector<bool> and array

What is "gratricide"?

Why should I vote and accept answers?

Hangman Game with C++

Is there a kind of relay that only consumes power when switching?

SF book about people trapped in a series of worlds they imagine

Using audio cues to encourage good posture

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Morning, Afternoon, Night Kanji

Is it fair for a professor to grade us on the possession of past papers?

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

Take 2! Is this homebrew Lady of Pain warlock patron balanced?

Generate an RGB colour grid

Do I really need to have a message in a novel to appeal to readers?

Time to Settle Down!

Why do we bend a book to keep it straight?

Is a ledger board required if the side of my house is wood?

An adverb for when you're not exaggerating

Question about debouncing - delay of state change

Why weren't discrete x86 CPUs ever used in game hardware?

Chinese Seal on silk painting - what does it mean?



How I can replace deprecated method this.stop() in ThreadGroup



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How I can replace deprecated method this.stop() in ThreadHow do I efficiently iterate over each entry in a Java Map?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How can I create an executable JAR with dependencies using Maven?How can I convert a stack trace to a string?Why is Java Vector (and Stack) class considered obsolete or deprecated?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?How to declare or mark a Java method as deprecated?Replacement for deprecated sizeWithFont: in iOS 7?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I am working on java version upgrade project and I am on the work where I need to replace deprecated methods.





this.stop();





Code USed this method are in ::



ThreadedTestGroup.java::



 package utmj.threaded;

import junit.framework.*;
public class ThreadedTestGroup extends ThreadGroup
private Test test;
private TestResult testResult;

public ThreadedTestGroup(Test test)
super("ThreadedTestGroup");
this.test = test;



public void interruptThenStop()
this.interrupt();
if (this.activeCount() > 0)
this.stop(); // For those threads which won't interrupt




public void setTestResult(TestResult result)
testResult = result;



public void uncaughtException(Thread t, Throwable e)
if (e instanceof ThreadDeath)
return;

if (e instanceof AssertionFailedError)
testResult.addFailure(test, (AssertionFailedError) e);
else
testResult.addError(test, e);

this.interruptThenStop();




CobcyrrentTestCase.java



 package utmj.threaded;

import java.util.*;

import junit.framework.*;

/
public class ConcurrentTestCase extends TestCase
private TestResult currentResult;
private ThreadedTestGroup threadGroup;
private Hashtable threads = new Hashtable();
private boolean deadlockDetected = false;
private Vector checkpoints = new Vector();

class ConcurrentTestThread extends Thread
private volatile boolean hasStarted = false;
private volatile boolean hasFinished = false;
ConcurrentTestThread(
ThreadGroup group,
Runnable runnable,
String name)
super(group, runnable, name);

public void run()
hasStarted = true;
super.run();
finishThread(this);



public ConcurrentTestCase(String name)
super(name);


public ConcurrentTestCase()
super();


protected void addThread(String name, final Runnable runnable)
if (threads.get(name) != null)
fail("Thread with name '" + name + "' already exists");

ConcurrentTestThread newThread =
new ConcurrentTestThread(threadGroup, runnable, name);
threads.put(name, newThread);


public synchronized void checkpoint(String checkpointName)
checkpoints.addElement(checkpointName);
this.notifyAll();


public boolean checkpointReached(String checkpointName)
return checkpoints.contains(checkpointName);


public boolean deadlockDetected()
return deadlockDetected;


private synchronized void finishThread(ConcurrentTestThread thread)
thread.hasFinished = true;
this.notifyAll();


private ConcurrentTestThread getThread(String threadName)
return (ConcurrentTestThread) threads.get(threadName);


/**
* Returns true if the thread finished normally, i.e. was not inerrupted or stopped
*/
public boolean hasThreadFinished(String threadName)
ConcurrentTestThread thread = this.getThread(threadName);
if (thread == null)
fail("Unknown Thread: " + threadName);

return thread.hasFinished;


public boolean hasThreadStarted(String threadName)
ConcurrentTestThread thread = this.getThread(threadName);
if (thread == null)
fail("Unknown Thread: " + threadName);

return thread.hasStarted;


private void interruptAllAliveThreads()
threadGroup.interruptThenStop();


/**
* Wait till all threads have finished. Wait maximally millisecondsToWait.
* Should only be called after startThreads().
*/
protected void joinAllThreads(long millisecondsToWait)
Enumeration enum1 = threads.elements();
long remainingMilliseconds = millisecondsToWait;
while (enum1.hasMoreElements())
long before = System.currentTimeMillis();
ConcurrentTestThread each =
(ConcurrentTestThread) enum1.nextElement();
try
each.join(remainingMilliseconds);
catch (InterruptedException ignored)

long spent = System.currentTimeMillis() - before;
if (millisecondsToWait != 0)
remainingMilliseconds = remainingMilliseconds - spent;
if (remainingMilliseconds <= 0)
deadlockDetected = true;
break;





public void joinThread(String threadName) throws InterruptedException
this.joinThread(threadName, 0);


public void joinThread(String threadName, long millisecondsToTimeout)
throws InterruptedException
ConcurrentTestThread thread = this.getThread(threadName);
if (thread == null)
fail("Unknown Thread: " + threadName);

thread.join(millisecondsToTimeout);


/**
* Stores the current result to be accessible during the test
*/
public void run(TestResult result)
currentResult = result;
super.run(result);


protected void setUp() throws Exception
threadGroup = new ThreadedTestGroup(this);


/**
* Sleep and ignore interruption
*/
public void sleep(long milliseconds)
try
Thread.sleep(milliseconds);
catch (InterruptedException ignored)



/**
* Run all threads and wait for them to finish without timeout
*/
protected void startAndJoinAllThreads()
this.startAndJoinThreads(0);



protected void startThreads()
threadGroup.setTestResult(currentResult);
Enumeration enum1 = threads.elements();
while (enum1.hasMoreElements())
ConcurrentTestThread each =
(ConcurrentTestThread) enum1.nextElement();
each.start();
each.hasStarted = true;

Thread.yield();




protected void tearDown() throws Exception
this.interruptAllAliveThreads();
threads = new Hashtable();
checkpoints = new Vector();
deadlockDetected = false;
threadGroup = null;
currentResult = null;


public synchronized void waitForCheckpoint(String checkpointName)
while (!this.checkpointReached(checkpointName))
try
this.wait();
catch (InterruptedException ignored)





public synchronized void waitUntilFinished(String threadName)
while (!this.hasThreadFinished(threadName))
try
this.wait();
catch (InterruptedException ignored)






I tried to search lot about this but did not got suitable solution so is there anyone who can help me out to replace this.stop() method which is deprecated.



IDE message: The method stop() from the type ThreadGroup is deprecated










share|improve this question






























    -1















    I am working on java version upgrade project and I am on the work where I need to replace deprecated methods.





    this.stop();





    Code USed this method are in ::



    ThreadedTestGroup.java::



     package utmj.threaded;

    import junit.framework.*;
    public class ThreadedTestGroup extends ThreadGroup
    private Test test;
    private TestResult testResult;

    public ThreadedTestGroup(Test test)
    super("ThreadedTestGroup");
    this.test = test;



    public void interruptThenStop()
    this.interrupt();
    if (this.activeCount() > 0)
    this.stop(); // For those threads which won't interrupt




    public void setTestResult(TestResult result)
    testResult = result;



    public void uncaughtException(Thread t, Throwable e)
    if (e instanceof ThreadDeath)
    return;

    if (e instanceof AssertionFailedError)
    testResult.addFailure(test, (AssertionFailedError) e);
    else
    testResult.addError(test, e);

    this.interruptThenStop();




    CobcyrrentTestCase.java



     package utmj.threaded;

    import java.util.*;

    import junit.framework.*;

    /
    public class ConcurrentTestCase extends TestCase
    private TestResult currentResult;
    private ThreadedTestGroup threadGroup;
    private Hashtable threads = new Hashtable();
    private boolean deadlockDetected = false;
    private Vector checkpoints = new Vector();

    class ConcurrentTestThread extends Thread
    private volatile boolean hasStarted = false;
    private volatile boolean hasFinished = false;
    ConcurrentTestThread(
    ThreadGroup group,
    Runnable runnable,
    String name)
    super(group, runnable, name);

    public void run()
    hasStarted = true;
    super.run();
    finishThread(this);



    public ConcurrentTestCase(String name)
    super(name);


    public ConcurrentTestCase()
    super();


    protected void addThread(String name, final Runnable runnable)
    if (threads.get(name) != null)
    fail("Thread with name '" + name + "' already exists");

    ConcurrentTestThread newThread =
    new ConcurrentTestThread(threadGroup, runnable, name);
    threads.put(name, newThread);


    public synchronized void checkpoint(String checkpointName)
    checkpoints.addElement(checkpointName);
    this.notifyAll();


    public boolean checkpointReached(String checkpointName)
    return checkpoints.contains(checkpointName);


    public boolean deadlockDetected()
    return deadlockDetected;


    private synchronized void finishThread(ConcurrentTestThread thread)
    thread.hasFinished = true;
    this.notifyAll();


    private ConcurrentTestThread getThread(String threadName)
    return (ConcurrentTestThread) threads.get(threadName);


    /**
    * Returns true if the thread finished normally, i.e. was not inerrupted or stopped
    */
    public boolean hasThreadFinished(String threadName)
    ConcurrentTestThread thread = this.getThread(threadName);
    if (thread == null)
    fail("Unknown Thread: " + threadName);

    return thread.hasFinished;


    public boolean hasThreadStarted(String threadName)
    ConcurrentTestThread thread = this.getThread(threadName);
    if (thread == null)
    fail("Unknown Thread: " + threadName);

    return thread.hasStarted;


    private void interruptAllAliveThreads()
    threadGroup.interruptThenStop();


    /**
    * Wait till all threads have finished. Wait maximally millisecondsToWait.
    * Should only be called after startThreads().
    */
    protected void joinAllThreads(long millisecondsToWait)
    Enumeration enum1 = threads.elements();
    long remainingMilliseconds = millisecondsToWait;
    while (enum1.hasMoreElements())
    long before = System.currentTimeMillis();
    ConcurrentTestThread each =
    (ConcurrentTestThread) enum1.nextElement();
    try
    each.join(remainingMilliseconds);
    catch (InterruptedException ignored)

    long spent = System.currentTimeMillis() - before;
    if (millisecondsToWait != 0)
    remainingMilliseconds = remainingMilliseconds - spent;
    if (remainingMilliseconds <= 0)
    deadlockDetected = true;
    break;





    public void joinThread(String threadName) throws InterruptedException
    this.joinThread(threadName, 0);


    public void joinThread(String threadName, long millisecondsToTimeout)
    throws InterruptedException
    ConcurrentTestThread thread = this.getThread(threadName);
    if (thread == null)
    fail("Unknown Thread: " + threadName);

    thread.join(millisecondsToTimeout);


    /**
    * Stores the current result to be accessible during the test
    */
    public void run(TestResult result)
    currentResult = result;
    super.run(result);


    protected void setUp() throws Exception
    threadGroup = new ThreadedTestGroup(this);


    /**
    * Sleep and ignore interruption
    */
    public void sleep(long milliseconds)
    try
    Thread.sleep(milliseconds);
    catch (InterruptedException ignored)



    /**
    * Run all threads and wait for them to finish without timeout
    */
    protected void startAndJoinAllThreads()
    this.startAndJoinThreads(0);



    protected void startThreads()
    threadGroup.setTestResult(currentResult);
    Enumeration enum1 = threads.elements();
    while (enum1.hasMoreElements())
    ConcurrentTestThread each =
    (ConcurrentTestThread) enum1.nextElement();
    each.start();
    each.hasStarted = true;

    Thread.yield();




    protected void tearDown() throws Exception
    this.interruptAllAliveThreads();
    threads = new Hashtable();
    checkpoints = new Vector();
    deadlockDetected = false;
    threadGroup = null;
    currentResult = null;


    public synchronized void waitForCheckpoint(String checkpointName)
    while (!this.checkpointReached(checkpointName))
    try
    this.wait();
    catch (InterruptedException ignored)





    public synchronized void waitUntilFinished(String threadName)
    while (!this.hasThreadFinished(threadName))
    try
    this.wait();
    catch (InterruptedException ignored)






    I tried to search lot about this but did not got suitable solution so is there anyone who can help me out to replace this.stop() method which is deprecated.



    IDE message: The method stop() from the type ThreadGroup is deprecated










    share|improve this question


























      -1












      -1








      -1


      1






      I am working on java version upgrade project and I am on the work where I need to replace deprecated methods.





      this.stop();





      Code USed this method are in ::



      ThreadedTestGroup.java::



       package utmj.threaded;

      import junit.framework.*;
      public class ThreadedTestGroup extends ThreadGroup
      private Test test;
      private TestResult testResult;

      public ThreadedTestGroup(Test test)
      super("ThreadedTestGroup");
      this.test = test;



      public void interruptThenStop()
      this.interrupt();
      if (this.activeCount() > 0)
      this.stop(); // For those threads which won't interrupt




      public void setTestResult(TestResult result)
      testResult = result;



      public void uncaughtException(Thread t, Throwable e)
      if (e instanceof ThreadDeath)
      return;

      if (e instanceof AssertionFailedError)
      testResult.addFailure(test, (AssertionFailedError) e);
      else
      testResult.addError(test, e);

      this.interruptThenStop();




      CobcyrrentTestCase.java



       package utmj.threaded;

      import java.util.*;

      import junit.framework.*;

      /
      public class ConcurrentTestCase extends TestCase
      private TestResult currentResult;
      private ThreadedTestGroup threadGroup;
      private Hashtable threads = new Hashtable();
      private boolean deadlockDetected = false;
      private Vector checkpoints = new Vector();

      class ConcurrentTestThread extends Thread
      private volatile boolean hasStarted = false;
      private volatile boolean hasFinished = false;
      ConcurrentTestThread(
      ThreadGroup group,
      Runnable runnable,
      String name)
      super(group, runnable, name);

      public void run()
      hasStarted = true;
      super.run();
      finishThread(this);



      public ConcurrentTestCase(String name)
      super(name);


      public ConcurrentTestCase()
      super();


      protected void addThread(String name, final Runnable runnable)
      if (threads.get(name) != null)
      fail("Thread with name '" + name + "' already exists");

      ConcurrentTestThread newThread =
      new ConcurrentTestThread(threadGroup, runnable, name);
      threads.put(name, newThread);


      public synchronized void checkpoint(String checkpointName)
      checkpoints.addElement(checkpointName);
      this.notifyAll();


      public boolean checkpointReached(String checkpointName)
      return checkpoints.contains(checkpointName);


      public boolean deadlockDetected()
      return deadlockDetected;


      private synchronized void finishThread(ConcurrentTestThread thread)
      thread.hasFinished = true;
      this.notifyAll();


      private ConcurrentTestThread getThread(String threadName)
      return (ConcurrentTestThread) threads.get(threadName);


      /**
      * Returns true if the thread finished normally, i.e. was not inerrupted or stopped
      */
      public boolean hasThreadFinished(String threadName)
      ConcurrentTestThread thread = this.getThread(threadName);
      if (thread == null)
      fail("Unknown Thread: " + threadName);

      return thread.hasFinished;


      public boolean hasThreadStarted(String threadName)
      ConcurrentTestThread thread = this.getThread(threadName);
      if (thread == null)
      fail("Unknown Thread: " + threadName);

      return thread.hasStarted;


      private void interruptAllAliveThreads()
      threadGroup.interruptThenStop();


      /**
      * Wait till all threads have finished. Wait maximally millisecondsToWait.
      * Should only be called after startThreads().
      */
      protected void joinAllThreads(long millisecondsToWait)
      Enumeration enum1 = threads.elements();
      long remainingMilliseconds = millisecondsToWait;
      while (enum1.hasMoreElements())
      long before = System.currentTimeMillis();
      ConcurrentTestThread each =
      (ConcurrentTestThread) enum1.nextElement();
      try
      each.join(remainingMilliseconds);
      catch (InterruptedException ignored)

      long spent = System.currentTimeMillis() - before;
      if (millisecondsToWait != 0)
      remainingMilliseconds = remainingMilliseconds - spent;
      if (remainingMilliseconds <= 0)
      deadlockDetected = true;
      break;





      public void joinThread(String threadName) throws InterruptedException
      this.joinThread(threadName, 0);


      public void joinThread(String threadName, long millisecondsToTimeout)
      throws InterruptedException
      ConcurrentTestThread thread = this.getThread(threadName);
      if (thread == null)
      fail("Unknown Thread: " + threadName);

      thread.join(millisecondsToTimeout);


      /**
      * Stores the current result to be accessible during the test
      */
      public void run(TestResult result)
      currentResult = result;
      super.run(result);


      protected void setUp() throws Exception
      threadGroup = new ThreadedTestGroup(this);


      /**
      * Sleep and ignore interruption
      */
      public void sleep(long milliseconds)
      try
      Thread.sleep(milliseconds);
      catch (InterruptedException ignored)



      /**
      * Run all threads and wait for them to finish without timeout
      */
      protected void startAndJoinAllThreads()
      this.startAndJoinThreads(0);



      protected void startThreads()
      threadGroup.setTestResult(currentResult);
      Enumeration enum1 = threads.elements();
      while (enum1.hasMoreElements())
      ConcurrentTestThread each =
      (ConcurrentTestThread) enum1.nextElement();
      each.start();
      each.hasStarted = true;

      Thread.yield();




      protected void tearDown() throws Exception
      this.interruptAllAliveThreads();
      threads = new Hashtable();
      checkpoints = new Vector();
      deadlockDetected = false;
      threadGroup = null;
      currentResult = null;


      public synchronized void waitForCheckpoint(String checkpointName)
      while (!this.checkpointReached(checkpointName))
      try
      this.wait();
      catch (InterruptedException ignored)





      public synchronized void waitUntilFinished(String threadName)
      while (!this.hasThreadFinished(threadName))
      try
      this.wait();
      catch (InterruptedException ignored)






      I tried to search lot about this but did not got suitable solution so is there anyone who can help me out to replace this.stop() method which is deprecated.



      IDE message: The method stop() from the type ThreadGroup is deprecated










      share|improve this question
















      I am working on java version upgrade project and I am on the work where I need to replace deprecated methods.





      this.stop();





      Code USed this method are in ::



      ThreadedTestGroup.java::



       package utmj.threaded;

      import junit.framework.*;
      public class ThreadedTestGroup extends ThreadGroup
      private Test test;
      private TestResult testResult;

      public ThreadedTestGroup(Test test)
      super("ThreadedTestGroup");
      this.test = test;



      public void interruptThenStop()
      this.interrupt();
      if (this.activeCount() > 0)
      this.stop(); // For those threads which won't interrupt




      public void setTestResult(TestResult result)
      testResult = result;



      public void uncaughtException(Thread t, Throwable e)
      if (e instanceof ThreadDeath)
      return;

      if (e instanceof AssertionFailedError)
      testResult.addFailure(test, (AssertionFailedError) e);
      else
      testResult.addError(test, e);

      this.interruptThenStop();




      CobcyrrentTestCase.java



       package utmj.threaded;

      import java.util.*;

      import junit.framework.*;

      /
      public class ConcurrentTestCase extends TestCase
      private TestResult currentResult;
      private ThreadedTestGroup threadGroup;
      private Hashtable threads = new Hashtable();
      private boolean deadlockDetected = false;
      private Vector checkpoints = new Vector();

      class ConcurrentTestThread extends Thread
      private volatile boolean hasStarted = false;
      private volatile boolean hasFinished = false;
      ConcurrentTestThread(
      ThreadGroup group,
      Runnable runnable,
      String name)
      super(group, runnable, name);

      public void run()
      hasStarted = true;
      super.run();
      finishThread(this);



      public ConcurrentTestCase(String name)
      super(name);


      public ConcurrentTestCase()
      super();


      protected void addThread(String name, final Runnable runnable)
      if (threads.get(name) != null)
      fail("Thread with name '" + name + "' already exists");

      ConcurrentTestThread newThread =
      new ConcurrentTestThread(threadGroup, runnable, name);
      threads.put(name, newThread);


      public synchronized void checkpoint(String checkpointName)
      checkpoints.addElement(checkpointName);
      this.notifyAll();


      public boolean checkpointReached(String checkpointName)
      return checkpoints.contains(checkpointName);


      public boolean deadlockDetected()
      return deadlockDetected;


      private synchronized void finishThread(ConcurrentTestThread thread)
      thread.hasFinished = true;
      this.notifyAll();


      private ConcurrentTestThread getThread(String threadName)
      return (ConcurrentTestThread) threads.get(threadName);


      /**
      * Returns true if the thread finished normally, i.e. was not inerrupted or stopped
      */
      public boolean hasThreadFinished(String threadName)
      ConcurrentTestThread thread = this.getThread(threadName);
      if (thread == null)
      fail("Unknown Thread: " + threadName);

      return thread.hasFinished;


      public boolean hasThreadStarted(String threadName)
      ConcurrentTestThread thread = this.getThread(threadName);
      if (thread == null)
      fail("Unknown Thread: " + threadName);

      return thread.hasStarted;


      private void interruptAllAliveThreads()
      threadGroup.interruptThenStop();


      /**
      * Wait till all threads have finished. Wait maximally millisecondsToWait.
      * Should only be called after startThreads().
      */
      protected void joinAllThreads(long millisecondsToWait)
      Enumeration enum1 = threads.elements();
      long remainingMilliseconds = millisecondsToWait;
      while (enum1.hasMoreElements())
      long before = System.currentTimeMillis();
      ConcurrentTestThread each =
      (ConcurrentTestThread) enum1.nextElement();
      try
      each.join(remainingMilliseconds);
      catch (InterruptedException ignored)

      long spent = System.currentTimeMillis() - before;
      if (millisecondsToWait != 0)
      remainingMilliseconds = remainingMilliseconds - spent;
      if (remainingMilliseconds <= 0)
      deadlockDetected = true;
      break;





      public void joinThread(String threadName) throws InterruptedException
      this.joinThread(threadName, 0);


      public void joinThread(String threadName, long millisecondsToTimeout)
      throws InterruptedException
      ConcurrentTestThread thread = this.getThread(threadName);
      if (thread == null)
      fail("Unknown Thread: " + threadName);

      thread.join(millisecondsToTimeout);


      /**
      * Stores the current result to be accessible during the test
      */
      public void run(TestResult result)
      currentResult = result;
      super.run(result);


      protected void setUp() throws Exception
      threadGroup = new ThreadedTestGroup(this);


      /**
      * Sleep and ignore interruption
      */
      public void sleep(long milliseconds)
      try
      Thread.sleep(milliseconds);
      catch (InterruptedException ignored)



      /**
      * Run all threads and wait for them to finish without timeout
      */
      protected void startAndJoinAllThreads()
      this.startAndJoinThreads(0);



      protected void startThreads()
      threadGroup.setTestResult(currentResult);
      Enumeration enum1 = threads.elements();
      while (enum1.hasMoreElements())
      ConcurrentTestThread each =
      (ConcurrentTestThread) enum1.nextElement();
      each.start();
      each.hasStarted = true;

      Thread.yield();




      protected void tearDown() throws Exception
      this.interruptAllAliveThreads();
      threads = new Hashtable();
      checkpoints = new Vector();
      deadlockDetected = false;
      threadGroup = null;
      currentResult = null;


      public synchronized void waitForCheckpoint(String checkpointName)
      while (!this.checkpointReached(checkpointName))
      try
      this.wait();
      catch (InterruptedException ignored)





      public synchronized void waitUntilFinished(String threadName)
      while (!this.hasThreadFinished(threadName))
      try
      this.wait();
      catch (InterruptedException ignored)






      I tried to search lot about this but did not got suitable solution so is there anyone who can help me out to replace this.stop() method which is deprecated.



      IDE message: The method stop() from the type ThreadGroup is deprecated







      java multithreading deprecated threadgroup






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 11 at 19:58







      James Bond

















      asked Mar 8 at 20:41









      James BondJames Bond

      25




      25






















          2 Answers
          2






          active

          oldest

          votes


















          1














          There is no single method that replaces stop() from Thread Group but rather a design approach



          From the oracle documentation it says




          Many uses of stop should be replaced by code that simply modifies
          some variable to indicate that the target thread should stop running.
          The target thread should check this variable regularly, and return
          from its run method in an orderly fashion if the variable indicates
          that it is to stop running




          Looking at the samples on What should I use instead of Thread.stop?



          private volatile Thread blinker;

          public void stop()
          blinker = null;


          public void run()
          Thread thisThread = Thread.currentThread();
          while (blinker == thisThread)
          try
          Thread.sleep(interval);
          catch (InterruptedException e)

          repaint();




          Throughout your thread, you need to check on a thread safe variable (in the example above its blinker) ... when stop is called, it sets the thread to null breaking out of the while loop and returning from run... thereby "stopping" the thread






          share|improve this answer























          • Can you look my post again I updated that with full codes where I am using all this threads things, help will be appreciated

            – James Bond
            Mar 11 at 20:01











          • Anything specific to look at, are your unit tests not working as intended?

            – Hedge7707
            Mar 11 at 20:34











          • Its looks like they are working, please give a look on screenshot : ibb.co/HH5CC7k even though I have to remove that this.stop() and I don't know its going to hamper the workflow or not?

            – James Bond
            Mar 11 at 22:19


















          0














          Well I red a bit of the documentation about why stop() is deprecated and here is the most relevant part :




          This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply m>odifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait.




          With those details, I think there is no more a simple way to stop all the threads as stop() did. You might need to modifie the threads so that you have a way to stop them (if it is possible for you).






          share|improve this answer























          • I tried by adding following variable can anybody tell me whether it is going to work or not? private Thread sample; public void interruptThenStop() + sample.interrupt(); + if (Thread.activeCount() > 0) + sample=null;

            – James Bond
            Mar 8 at 20:57












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070699%2fhow-i-can-replace-deprecated-method-this-stop-in-threadgroup%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          There is no single method that replaces stop() from Thread Group but rather a design approach



          From the oracle documentation it says




          Many uses of stop should be replaced by code that simply modifies
          some variable to indicate that the target thread should stop running.
          The target thread should check this variable regularly, and return
          from its run method in an orderly fashion if the variable indicates
          that it is to stop running




          Looking at the samples on What should I use instead of Thread.stop?



          private volatile Thread blinker;

          public void stop()
          blinker = null;


          public void run()
          Thread thisThread = Thread.currentThread();
          while (blinker == thisThread)
          try
          Thread.sleep(interval);
          catch (InterruptedException e)

          repaint();




          Throughout your thread, you need to check on a thread safe variable (in the example above its blinker) ... when stop is called, it sets the thread to null breaking out of the while loop and returning from run... thereby "stopping" the thread






          share|improve this answer























          • Can you look my post again I updated that with full codes where I am using all this threads things, help will be appreciated

            – James Bond
            Mar 11 at 20:01











          • Anything specific to look at, are your unit tests not working as intended?

            – Hedge7707
            Mar 11 at 20:34











          • Its looks like they are working, please give a look on screenshot : ibb.co/HH5CC7k even though I have to remove that this.stop() and I don't know its going to hamper the workflow or not?

            – James Bond
            Mar 11 at 22:19















          1














          There is no single method that replaces stop() from Thread Group but rather a design approach



          From the oracle documentation it says




          Many uses of stop should be replaced by code that simply modifies
          some variable to indicate that the target thread should stop running.
          The target thread should check this variable regularly, and return
          from its run method in an orderly fashion if the variable indicates
          that it is to stop running




          Looking at the samples on What should I use instead of Thread.stop?



          private volatile Thread blinker;

          public void stop()
          blinker = null;


          public void run()
          Thread thisThread = Thread.currentThread();
          while (blinker == thisThread)
          try
          Thread.sleep(interval);
          catch (InterruptedException e)

          repaint();




          Throughout your thread, you need to check on a thread safe variable (in the example above its blinker) ... when stop is called, it sets the thread to null breaking out of the while loop and returning from run... thereby "stopping" the thread






          share|improve this answer























          • Can you look my post again I updated that with full codes where I am using all this threads things, help will be appreciated

            – James Bond
            Mar 11 at 20:01











          • Anything specific to look at, are your unit tests not working as intended?

            – Hedge7707
            Mar 11 at 20:34











          • Its looks like they are working, please give a look on screenshot : ibb.co/HH5CC7k even though I have to remove that this.stop() and I don't know its going to hamper the workflow or not?

            – James Bond
            Mar 11 at 22:19













          1












          1








          1







          There is no single method that replaces stop() from Thread Group but rather a design approach



          From the oracle documentation it says




          Many uses of stop should be replaced by code that simply modifies
          some variable to indicate that the target thread should stop running.
          The target thread should check this variable regularly, and return
          from its run method in an orderly fashion if the variable indicates
          that it is to stop running




          Looking at the samples on What should I use instead of Thread.stop?



          private volatile Thread blinker;

          public void stop()
          blinker = null;


          public void run()
          Thread thisThread = Thread.currentThread();
          while (blinker == thisThread)
          try
          Thread.sleep(interval);
          catch (InterruptedException e)

          repaint();




          Throughout your thread, you need to check on a thread safe variable (in the example above its blinker) ... when stop is called, it sets the thread to null breaking out of the while loop and returning from run... thereby "stopping" the thread






          share|improve this answer













          There is no single method that replaces stop() from Thread Group but rather a design approach



          From the oracle documentation it says




          Many uses of stop should be replaced by code that simply modifies
          some variable to indicate that the target thread should stop running.
          The target thread should check this variable regularly, and return
          from its run method in an orderly fashion if the variable indicates
          that it is to stop running




          Looking at the samples on What should I use instead of Thread.stop?



          private volatile Thread blinker;

          public void stop()
          blinker = null;


          public void run()
          Thread thisThread = Thread.currentThread();
          while (blinker == thisThread)
          try
          Thread.sleep(interval);
          catch (InterruptedException e)

          repaint();




          Throughout your thread, you need to check on a thread safe variable (in the example above its blinker) ... when stop is called, it sets the thread to null breaking out of the while loop and returning from run... thereby "stopping" the thread







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 20:58









          Hedge7707Hedge7707

          422514




          422514












          • Can you look my post again I updated that with full codes where I am using all this threads things, help will be appreciated

            – James Bond
            Mar 11 at 20:01











          • Anything specific to look at, are your unit tests not working as intended?

            – Hedge7707
            Mar 11 at 20:34











          • Its looks like they are working, please give a look on screenshot : ibb.co/HH5CC7k even though I have to remove that this.stop() and I don't know its going to hamper the workflow or not?

            – James Bond
            Mar 11 at 22:19

















          • Can you look my post again I updated that with full codes where I am using all this threads things, help will be appreciated

            – James Bond
            Mar 11 at 20:01











          • Anything specific to look at, are your unit tests not working as intended?

            – Hedge7707
            Mar 11 at 20:34











          • Its looks like they are working, please give a look on screenshot : ibb.co/HH5CC7k even though I have to remove that this.stop() and I don't know its going to hamper the workflow or not?

            – James Bond
            Mar 11 at 22:19
















          Can you look my post again I updated that with full codes where I am using all this threads things, help will be appreciated

          – James Bond
          Mar 11 at 20:01





          Can you look my post again I updated that with full codes where I am using all this threads things, help will be appreciated

          – James Bond
          Mar 11 at 20:01













          Anything specific to look at, are your unit tests not working as intended?

          – Hedge7707
          Mar 11 at 20:34





          Anything specific to look at, are your unit tests not working as intended?

          – Hedge7707
          Mar 11 at 20:34













          Its looks like they are working, please give a look on screenshot : ibb.co/HH5CC7k even though I have to remove that this.stop() and I don't know its going to hamper the workflow or not?

          – James Bond
          Mar 11 at 22:19





          Its looks like they are working, please give a look on screenshot : ibb.co/HH5CC7k even though I have to remove that this.stop() and I don't know its going to hamper the workflow or not?

          – James Bond
          Mar 11 at 22:19













          0














          Well I red a bit of the documentation about why stop() is deprecated and here is the most relevant part :




          This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply m>odifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait.




          With those details, I think there is no more a simple way to stop all the threads as stop() did. You might need to modifie the threads so that you have a way to stop them (if it is possible for you).






          share|improve this answer























          • I tried by adding following variable can anybody tell me whether it is going to work or not? private Thread sample; public void interruptThenStop() + sample.interrupt(); + if (Thread.activeCount() > 0) + sample=null;

            – James Bond
            Mar 8 at 20:57
















          0














          Well I red a bit of the documentation about why stop() is deprecated and here is the most relevant part :




          This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply m>odifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait.




          With those details, I think there is no more a simple way to stop all the threads as stop() did. You might need to modifie the threads so that you have a way to stop them (if it is possible for you).






          share|improve this answer























          • I tried by adding following variable can anybody tell me whether it is going to work or not? private Thread sample; public void interruptThenStop() + sample.interrupt(); + if (Thread.activeCount() > 0) + sample=null;

            – James Bond
            Mar 8 at 20:57














          0












          0








          0







          Well I red a bit of the documentation about why stop() is deprecated and here is the most relevant part :




          This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply m>odifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait.




          With those details, I think there is no more a simple way to stop all the threads as stop() did. You might need to modifie the threads so that you have a way to stop them (if it is possible for you).






          share|improve this answer













          Well I red a bit of the documentation about why stop() is deprecated and here is the most relevant part :




          This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply m>odifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait.




          With those details, I think there is no more a simple way to stop all the threads as stop() did. You might need to modifie the threads so that you have a way to stop them (if it is possible for you).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 20:53









          TheFlyingKing 77TheFlyingKing 77

          11




          11












          • I tried by adding following variable can anybody tell me whether it is going to work or not? private Thread sample; public void interruptThenStop() + sample.interrupt(); + if (Thread.activeCount() > 0) + sample=null;

            – James Bond
            Mar 8 at 20:57


















          • I tried by adding following variable can anybody tell me whether it is going to work or not? private Thread sample; public void interruptThenStop() + sample.interrupt(); + if (Thread.activeCount() > 0) + sample=null;

            – James Bond
            Mar 8 at 20:57

















          I tried by adding following variable can anybody tell me whether it is going to work or not? private Thread sample; public void interruptThenStop() + sample.interrupt(); + if (Thread.activeCount() > 0) + sample=null;

          – James Bond
          Mar 8 at 20:57






          I tried by adding following variable can anybody tell me whether it is going to work or not? private Thread sample; public void interruptThenStop() + sample.interrupt(); + if (Thread.activeCount() > 0) + sample=null;

          – James Bond
          Mar 8 at 20:57


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070699%2fhow-i-can-replace-deprecated-method-this-stop-in-threadgroup%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved