Avoiding the use of deprecated methods
The Java concurrency API also has deprecated operations. These are operations that were included in the first versions of the API, but now you shouldn't use them. They have been replaced by other operations that implement better practices than the original ones.
The more critical deprecated operations are those that are provided by the Thread
class. These operations are:
destroy()
: In the past, this method destroyed the thread. Actually, it throws aNoSuchMethodError
exception.suspend()
: This method suspends the execution of the thread until it's resumed.stop()
: This method forces the thread to finish its execution.resume()
: This method resumes the execution of the thread.
The ThreadGroup
class also has some deprecated methods, which are as follows:
suspend()
: This method suspends the execution of all the threads that belong to this thread group until they resumestop()
: This method forces the execution of all the threads of this thread group to finishresume...