About the author
In the two comic viewers, portions of the application retrieves images from the web in the background, using a thread. While coding up a solution, I remembered that thread control is problematic, and utilizing my Delphi experience, I coded the terminate and isTerminated methods.
Combining Delphi experience with Sun's recommendation, the two new methods set, or returns the value of a volatile boolean. In the thread execution, the Run method calls either isTerminated method, or checks the mTerminated boolean and continues execution if it's false.
mThread = new StoppableThread() { public void run() { do {// work } while (!mTerminated)); }}
Since threads works with Runnables, when I coded up the terminate method, I added a check to see if the thread has a Runnable instance associated with it, and if so, calls it's terminate method as well.
public void terminate() { if (mRunnable instanceof StoppableRunnable) ((StoppableRunnable) mRunnable).terminate(); mTerminated = true; }
Continued discussion of undocumented Delphi 8 Property Access Specifiers, and other ways of adding and removing delegates / events handlers, including clearing the list of all the delegates / event handlers.
This article discusses the new Delphi 8 property access specifiers.
A method pointer is now the same as a global procedure, ie, procedure of object = procedure.