Wiki Markup |
---|
Starting and using background threads during class initialization can result in class initialization cycles and eventually, deadlock. This is because the main thread responsible for performing class initialization may block waiting for the background thread, which in turn will wait for the main thread to finish class initialization. This issue can arise, for example, when a database connection is established in a background thread while class initialization is underway. \[[Bloch 05b|AA. Java References#Bloch 05b]\] |
Noncompliant Code Example (background thread)
This noncompliant code example begins initializing the class Lazy
. The code in the static
block is responsible for initialization, and starts a background thread. The background thread attempts to initialize a database connection but needs to wait until initialization of all members of the Lazy
class, including dbConnection
, has finished.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
CON03- J | low | likely | high | P3 | L3 |
Automated Detection
...
Currently, SureLogic Flashlight does not detect all violations of this guideline. It does not detect:
Noncompliant Code Example | Message |
---|---|
background thread | No data available about field accesses |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...