Description Summary If two threads of execution use a resource simultaneously,
there exists the possibility that resources may be used while invalid, in turn
making the state of execution undefined.
Example 1 (Bad Code) C and C++ int foo = 0; int storenum(int num) { static int counter = 0;
counter++;
if (num > foo) foo = num;
return foo;
} (Bad Code) Java public classRace { static int foo = 0;
public static void main() {
new Threader().start();
foo = 1;
}
public static class Threader extends Thread {
public void run() {
System.out.println(foo);
}
}
}
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Page Last Updated:
October 29, 2009
|
|
CWE is a Software Assurance strategic initiative sponsored by the National Cyber Security Division of the U.S. Department of Homeland Security. This Web site is hosted by The MITRE Corporation. Contact cwe@mitre.org for more information. |
|||
