---
title: "CWE-383: J2EE Bad Practices: Direct Use of Threads"
url: https://radicalnotion.ai/cwe/cwe-383
type: cwe
description: "Thread management in a Web application is forbidden in some circumstances and is always highly error prone."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-383: J2EE Bad Practices: Direct Use of Threads

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

Thread management in a Web application is forbidden in some circumstances and is always highly error prone.

## Background

Thread management in a web application is forbidden by the J2EE standard in some circumstances and is always highly error prone. Managing threads is difficult and is likely to interfere in unpredictable ways with the behavior of the application container.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Java (Undetermined)

**Technologies:** Web Based (Undetermined), Web Server (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Quality Degradation, Varies by Context | Even without interfering with the container, thread management usually leads to bugs that are hard to detect and diagnose, such as deadlock, race conditions, and other synchronization errors. |

## Potential mitigations

### Architecture and Design

For EJB, use framework approaches for parallel execution, instead of using threads.

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Effectiveness: High

## Demonstrative examples

### 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();
}
```

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-695](https://radicalnotion.ai/cwe/cwe-695) | Use of Low-Level Functionality |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | J2EE Bad Practices: Threads | - | - |
| Software Fault Patterns | Use of an improper API | SFP3 | - |

## Frequently asked questions

### What is CWE-383?

Thread management in a Web application is forbidden in some circumstances and is always highly error prone.

### How do you prevent CWE-383?

For EJB, use framework approaches for parallel execution, instead of using threads.

### How is CWE-383 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-383?

Exploiting CWE-383 can lead to: Quality Degradation, Varies by Context.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/383.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-383). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
