No Peter Pan objects
From CSSEMediaWiki
(Difference between revisions)
(→Solutions) |
|
(One intermediate revision by one user not shown) |
Latest revision as of 03:11, 25 November 2010
Do not create something that lives forever and lose track of it.
When creating objects that may linger indefinitely especially those who have their own resident thread always keep a reference. For purposes such as pausing a program's execution it is vital to have a handle to each object that may have a separate execution path.
Solutions
- Chain of responsibility - Make each object responsible for passing thread control messages to any children it instantiated.
- Singleton - Create a thread registry, this will contain methods to construct a new thread for a client and maintain a list of threads that have been constructed. This way the registry can directly manage the execution state of threads.