There are two approaches to making your classes behave as threads:
Which approach you choose depends on your application's needs and the constraints placed on it. Giving your class the capability to run as a thread does not automatically make it run as such. When a class is called runnable, that means it has the ability to act as a separate thread, but not necessarily that it is running as a separate thread. The reason for this is that the start method that is defined in the Runnable interface must be called to start the thread running. You'll learn more about the start method later in this chapter. |