In java multi-threaded program, a thread can be created using both by extending Thread class and Implementing Runnable interface.
How do you create multiple threads in Java?
Multithreading in Java
- Thread creation by extending the Thread class. We create a class that extends the java. lang. Thread class. ...
- Thread creation by implementing the Runnable Interface. We create a new class which implements java. lang. Runnable interface and override run() method. ...
- Thread Class vs Runnable Interface.
How many ways a thread can be created in Java multithreading?
There are two ways we can create a thread in multithreading in java programs that is by extending thread class and implementing Runnable interface.