What is thread in Java?

DWQA QuestionsCategory: QuestionsWhat is thread in Java?
1 Answers
Editor Staff answered 4 weeks ago

Threads allows a program to operate more efficiently by doing multiple things at the same time.
Threads can be used to perform complicated tasks in the background without interrupting the main program.
It can be created by extending the Thread class and overriding its run() method:
Extend Syntax
public class MyClass extends Thread {
public void run() {
System.out.println(“This code is running in a thread”);
}
}