Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Similarly, it is inappropriate to start threads from constructors (see rule TSM01-J. Do not let the ( this ) reference escape during object construction for more information). Creating timers that perform recurring tasks and starting those timers from within code responsible for initialization also introduces liveness issues.

...

Wiki Markup
<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:macro-id="ce4c1c51bcab731d-d7955c9b-497b4fe0-82c5b4e8-378cb8a43b4626a1cfaa78be"><ac:parameter ac:name="">CON20-EX1</ac:parameter></ac:structured-macro>
*TSM02-EX0:* Programs are permitted to start a background thread (or threads) during class initialization, provided the thread cannot access any fields. For example, the {{ObjectPreserver}} class (based on \[[Grand 2002|AA. Bibliography#Grand 02]\]) shown below provides a mechanism for storing object references, which prevents an object from being garbage-collected, even when the object is never again de-referenced.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4f4721567ce302ac-deb47b5c-4e974e5e-b3d7a6cd-57d02d2e7cd8ff48b9c1b031"><ac:plain-text-body><![CDATA[

[[Bloch 2005b

AA. Bibliography#Bloch 05b]]

8. "Lazy Initialization"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3797b02f196aed10-f2ea4601-40ab460f-a0b7a616-987cec7ba379a82ced0772d1"><ac:plain-text-body><![CDATA[

[[Grand 2002

AA. Bibliography#Grand 02]]

Chapter 5, Creational Patterns, Singleton

]]></ac:plain-text-body></ac:structured-macro>

...

Tasklist
Review List
Review List
||Completed||Priority||Locked||CreatedDate||CompletedDate||Assignee||Name||
|T|M|F|1269649993019|1269700561582|rcs_mgr|"Starting and using background threads during class initialization can result in class initialization cycles and deadlock. *For instance,* 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." ... see suggested words in bold...I am also generally unsure about the use of "can" vs. "may" because deadlocks are a "possibility" so perhaps "may" should be used?|

...

TSM01-J. Do not let the (this) reference escape during object constructionImage Added      11. Thread-Safety Miscellaneous (TSM)