Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Parasoft Jtest 2021.1

...

However, the Thread.stop() method causes the thread to stop what it is doing and throw a ThreadDeath exception. All acquired locks are subsequently released [API 20062014]. If the thread were in the process of adding a new integer to the vector when it was stopped, the vector would become accessible while it is in an inconsistent state. For example, this could result in Vector.size() returning an incorrect element count because the element count is incremented after adding the element.

...

Forcing a thread to stop can result in inconsistent object state. Critical resources could also leak if cleanup operations are not carried out as required.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

THI05-J

Low

Probable

Medium

P4

L3

Automated Detection

ToolVersionCheckerDescription
Parasoft Jtest
Include Page
Parasoft_V
Parasoft_V
CERT.THI05.THRDAvoid calling unsafe deprecated methods of 'Thread' and 'Runtime'

Related Guidelines

Android Implementation Details

On Android, Thread.stop() was deprecated in API level 1.

Bibliography

[API 2006]

Class Thread, Method stop
InterfaceExecutorService

[Darwin 2004]

Section 24.3, "Stopping a Thread"

[Goetz 2006]

Chapter 7, "Cancellation and Shutdown"

[JavaThreads 2004]

Section 2.4, "Two Approaches to Stopping a Thread"

[JDK7 2008]

Concurrency Utilities, More information: Java Thread Primitive Deprecation

[JPL 2006]

Section 14.12.1, "Don't Stop"
Section 23.3.3, "Shutdown Strategies

"

[JavaThreads 2004]

Section 2.4,

"

Two Approaches to Stopping a Thread"

[Sun 1999]

 

...



...