header-logo.png GKINDEX

Start a Java thread

There are two ways to create a new thread.

  • Extending the Thread class

  • Implementing the Runnable interface

Extending the Thread Class

The following is the example of creation of a new thread by extending the Thread Class.

Implementing the Runnable interface

In the above example, we are implementing the Runnable interface and creating the Object of CreationOfThread class, And passing the Object of the CreationOfThread class to the Thread class constructor.After that we are starting a thread.

  • Share