Java Multi-Threading Question:

Explain Thread?

Tweet Share WhatsApp

Answer:

We can describe "thread" in two ways in Java.

1. An instance of class java.lang.Thread.
2. A thread of execution.

An instance of Thread is an object like all other objects in Java, it also has variables and methods and it lives and dies on the heap.

But a thread of execution is an individual light weight process that has its own call stack.
Even if you don't create any new threads in your program, threads are there running in background.
The main() method runs the main thread. So in main call stack the main() method would be the first.
When a new thread is created then it will have its own stack separate from the main() call stack.

Download Java Multi-Threading PDF Read All 36 Java Multi-Threading Questions
Previous QuestionNext Question
What is starvation?Explain some ways in which a thread can enter the waiting state?