Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Thread startup can be misleading because the code can appear to be performing the its function correctly when it is actually being executed by the wrong thread.
Invoking the Thread.start() method instructs the Java runtime to start executing the thread's run() method using the started thread. Invoking a Thread object's run() method directly is incorrect. When a Thread object's run() method is invoked directly, the statements in the run() method are executed by the current thread rather than by the newly created thread. Furthermore, if the Thread object was constructed by instantiating a subclass of Thread that fails to override the run() method rather than constructed from a Runnable object, any calls to the subclass's run() method would invoke Thread.run(), which does nothing. Consequently, programs must not directly invoke a Thread object's run() method.

...

Automated detection of direct invocations of Thread object's .run() methods is straightforward. Sound automated determination of which specific invocations are permitted may be infeasible. Heuristic approaches may be useful.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="428cc47b8dc3f153-442b84c2-49be48c1-8680a591-84f959375664a2979bacf0d1"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

Interface Runnable and class Thread

]]></ac:plain-text-body></ac:structured-macro>

...