Understanding Thread Group Security

Chapter 11 - Self-Running Objects

Java Thread Programming
Paul Hyde
  Copyright 1999 Sams Publishing

Summary
In this chapter, I showed you a technique for creating active classes that are self-running. Self-running classes automatically create an internal thread that runs inside the object. This thread is usually started in the constructor, but can be started later if necessary. Users of self-running objects do not need to concern themselves with the details of creating and starting a thread for an objectin fact, they dont even need to know that a thread is running inside it at all. Additionally, because the users of a self-running object do not have a reference to the internal thread, they cannot erroneously use deprecated methods to suspend or stop the thread at a bad time.
Of the two self-running designs presented, I recommend that you use the one that hides run() within an anonymous, inner class. This design has the advantage of preventing a user from mistakenly invoking run() directly, or from mistakenly creating a new thread that invokes run() .

Toc


Java Thread Programming
Java Thread Programming
ISBN: 0672315858
EAN: 2147483647
Year: 2005
Pages: 149
Authors: Paul Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net