结构: Simple
Abstraction: Variant
状态: Draft
被利用可能性: unkown
The program calls a thread's run() method instead of calling start(), which causes the code to run in the thread of the caller instead of the callee.
In most cases a direct call to a Thread object's run() method is a bug. The programmer intended to begin a new thread of control, but accidentally called run() instead of start(), so the run() method will execute in the caller's thread of control.
cwe_Nature: ChildOf cwe_CWE_ID: 821 cwe_View_ID: 1000 cwe_Ordinal: Primary
cwe_Nature: ChildOf cwe_CWE_ID: 821 cwe_View_ID: 699 cwe_Ordinal: Primary
Language: {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}
范围 | 影响 | 注释 |
---|---|---|
Other | ['Quality Degradation', 'Varies by Context'] |
策略:
Use the start() method instead of the run() method.
The following excerpt from a Java program mistakenly calls run() instead of start().
bad Java
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
The CERT Oracle Secure Coding Standard for Java (2011) | THI00-J | Do not invoke Thread.run() | |
Software Fault Patterns | SFP3 | Use of an improper API |