December 1999
Intermediate to advanced
816 pages
20h 27m
English
There are two ways to create a Thread object. Listing 11.1 shows the approach you should use most often (from an object-oriented design perspective).
You can create a Thread in two ways. You may create a Thread using an instance of a class that implements the Runnable interface. This is the best choice generally from an object-oriented design perspective. Or, you can subclass the Thread class to make an object that inherits from Thread. The former, generally superior approach is shown in Listing 11.1.
class BookFinder implements Runnable // Threads need a Runnable object for their constructor. ... |
Read now
Unlock full access