...
Wiki Markup |
---|
<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:macro-id="5a0c049cafba7e85-1849f7a6-4ad5465f-8ef1a822-5994d85b1c5e96731c96ab9d"><ac:parameter ac:name="">CON20-EX1</ac:parameter></ac:structured-macro> *CON20-EX1:* It is permissible to start a background thread during class initialization provided the thread does not access any fields. For example, the {{ObjectPreserver}} class (based on \[[Patterns 02|AA. Java References#Patterns 02]\]) shown below provides a mechanism for storing object references, which prevents an object from being garbage-collected, even if the object is not dereferenced in the future. |
...
11. Concurrency (CON) CON21THI02-J. Do not invoke Thread.run()