
7.16 Errors and Exceptions in Java and Multithreaded Programming
7.13 How to Create and Run the Threads?
By default, our main program is running on the main thread. To create our own threads the
following steps are used.
• Step1: A thread can be created either by extending to the thread class or implementing
the runnable interface.
Example: class ThreadTest extends Thread or
Class ThreadTest implements Runnable
• Step2 : Inside the class define run() method. Inside run method, we can implement thread
functionality. Run() method is automatically recognized and executed by the thread.
class ThreadTest extends Thread{ or
class ThreadTest extends ...