Description Summary Thread management in a Web application is forbidden in some
circumstances and is always highly error prone.
Example 1 In the following example, a new Thread object is created and invoked directly from within the body of a doGet() method in a Java servlet. (Bad Code) Java public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException { // Perform servlet tasks.
...
// Create a new thread to handle background processing.
Runnable r = new Runnable() {
public void run() {
// Process and store request statistics.
...
}
};
new Thread(r).start();
}
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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. |
|||
