Advanced Java Tutorial

Total available pages count: 55
Subject - Java Technologies

Creating thread

We can create a thread in 2 way:

  • By extends the thread class
  • By implementing a runnable interface

Thread class

This class has a collection of constructors & methods to create and perform the various operation on the extends object class & implements the runnable interface.

Some common constructors,

Thread(String name)
Thread(Runnable r)
Thread(Runnable r,String name)


Runnable interface

The runnable interface can be implemented by the class of instances that are intended to be executed by a thread. it has only run() method to perform an action for a thread.