How we can define a Thread in java

Thread can define in two ways in java. By extending a Thread class and by implementing a Runnable interface.

  1. by extending Thread class
  2. by implementing Runnable interface

Example to define Thread by extending Thread class

Output:

Example to define Thread by implementing Runnable interface

Output:

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.