|
Execution in Java always take form of a thread. In simple programs only one thread occurs, often referred to as the "main thread".In some programs though concurrent threads is necessary, or if you are building a Swing application with for example a progress bar you dont want the main thread to handle the updates of the UI. Then you create an additional thread to take care of that. There are two main ways of creating a thread. The first is to extend the Thread class and the second is to implement the Runnable interface.
Extending Thread: This examplse shows how you can create a thread in java by extending the thread interface. |