answersLogoWhite

0

You can define and instantiate a thread in one of two ways:

• Extend the java.lang.Thread class.

• Implement the Runnable interface.

class MyFirstThread extends Thread {

public void run() {

System.out.println("Important job running in MyFirstThread");

}

}

or

class MyFirstRunnableClass implements Runnable {

public void run() {

System.out.println("Imp job running in MyFirstRunnableClass");

}

}

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi

Add your answer:

Earn +20 pts
Q: What are the different ways of implementing thread in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp