Call to Thread run() instead of start() |
Weakness ID: 572 (Weakness Variant) | Status: Draft |
Description Summary
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.
Extended Description
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.
Example 1
The following excerpt from a Java program mistakenly calls run() instead of start().
(Bad Code)
Example Language: Java
Thread thr = new Thread() {
public void run() {
...
}
};
thr.run();
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 366 | Race Condition within a Thread | Development Concepts (primary)699 Research Concepts (primary)1000 |
ChildOf | ![]() | 557 | Concurrency Issues | Development Concepts699 |
ChildOf | ![]() | 634 | Weaknesses that Affect System Processes | Resource-specific Weaknesses (primary)631 |
Modifications | ||||
---|---|---|---|---|
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Potential Mitigations, Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Relationships, Other Notes | ||||
2009-05-27 | CWE Content Team | MITRE | Internal | |
updated Demonstrative Examples | ||||
2009-07-27 | CWE Content Team | MITRE | Internal | |
updated Description, Other Notes | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2008-04-11 | Call to Thread.run() | |||