Multithreading is one of the most frequently asked topics in Java interviews.

It allows Java programs to perform multiple tasks simultaneously, improving performance and responsiveness — especially in real-world applications like chat servers, web applications, file processing, and games.

In this article, we’ll cover the Top 25 Multithreading Interview Questions with detailed answers and examples to help you master the concept.


1. What is a thread in Java?

A thread is a lightweight sub-process — the smallest unit of CPU execution.

Each thread runs independently but shares the same memory area with other threads in the process.


public class MyThread extends Thread {
    public void run() {
        System.out.println("Thread is running...");
    }

    public static void main(String[] args) {
        MyThread t1 = new MyThread();
        t1.start(); // starts a new thread
    }
}

Here, calling start() creates a new thread that executes the run() method.


2. What is multithreading, and why is it used?

Multithreading is the process of executing multiple threads simultaneously to maximize CPU utilization.

Advantages:

  • Better performance on multi-core systems
  • Improved responsiveness (UI remains active while tasks run)
  • Efficient CPU usage — idle time is minimized
  • Useful in games, web servers, chat systems, etc.

3. Difference between process and thread?

FeatureProcessThread
DefinitionIndependent program under executionLightweight sub-process
MemoryEach process has its own memoryThreads share memory of the process
CommunicationInter-process communication is slowerThread communication is faster
Crash ImpactOne process crash doesn’t affect othersOne thread crash may affect all threads in the process

4. How to create a thread in Java?

You can create a thread in two ways:

1. By extending the Thread class


class MyThread extends Thread {
    public void run() {
        System.out.println("Thread running using Thread class");
    }

    public static void main(String[] args) {
        new MyThread().start();
    }
}

2. By implementing Runnable interface


class MyRunnable implements Runnable {
    public void run() {
        System.out.println("Thread running using Runnable interface");
    }

    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable());
        t.start();
    }
}

Runnable is preferred as it allows multiple threads to share the same object.


5. Difference between Thread class and Runnable interface?

AspectThreadRunnable
InheritanceExtends Thread class (can’t extend another class)Implements Runnable (multiple inheritance possible)
Resource SharingEach thread has its own objectMultiple threads can share one Runnable object
RecommendedLess flexibleMore flexible and preferred

6. Can we start a thread twice in Java?

No. Once a thread has started, you cannot start it again. Doing so throws IllegalThreadStateException.


Thread t = new Thread();
t.start();
t.start(); // ❌ IllegalThreadStateException

7. What happens if we call run() instead of start()?

If you call run() directly, it executes like a normal method in the same thread — no new thread is created.


t.run();   // runs in main thread
t.start(); // runs in new thread

8. What is thread lifecycle in Java?

A thread passes through several states in its lifetime:

  1. New – Thread created but not started.
  2. Runnable – Ready to run by the CPU.
  3. Running – Thread currently executing.
  4. Blocked/Waiting – Waiting for resources or another thread.
  5. Terminated – Thread has finished execution.

9. Explain the states of a thread with a diagram.

Thread States:


NEW → RUNNABLE → RUNNING → WAITING/BLOCKED → TERMINATED

Example:


Thread t = new Thread();
System.out.println(t.getState()); // NEW
t.start();
System.out.println(t.getState()); // RUNNABLE or RUNNING

10. What are daemon threads?

Daemon threads are background threads that provide services to user threads.

They automatically terminate when all user threads finish execution (e.g., Garbage Collector).


11. How do you create a daemon thread?


Thread t = new Thread(() -> System.out.println("Daemon running"));
t.setDaemon(true);
t.start();

Note: You must call setDaemon(true) before starting the thread.


12. Difference between user thread and daemon thread

TypeDescription
User ThreadMain program threads — JVM waits for them to complete.
Daemon ThreadBackground threads — JVM exits when only daemon threads remain.

13. What is thread priority?

Thread priority determines which thread gets preference for CPU execution.

Priority values range from 1 (MIN_PRIORITY) to 10 (MAX_PRIORITY).


14. What is the default thread priority in Java?

The default priority is 5 (NORM_PRIORITY).


15. How can we change thread priority?


Thread t = new Thread();
t.setPriority(Thread.MAX_PRIORITY);
System.out.println(t.getPriority()); // 10

16. What is the difference between sleep() and wait()?

Aspectsleep()wait()
Belongs toThread classObject class
Lock releaseDoes not release lockReleases lock
PurposePause thread for given timeUsed for inter-thread communication

17. What is yield() method used for?

yield() causes the currently executing thread to pause and allow other threads of equal priority to execute.


Thread.yield();

18. Can a thread be restarted once it has finished execution?

No. Once a thread has finished (state = TERMINATED), it cannot be restarted.


19. What is thread scheduling?

Thread scheduling is the process by which the JVM decides which thread will execute next.

It depends on:

  • Thread priority
  • Thread state
  • Thread scheduler implementation (OS dependent)

20. What is a race condition?

A race condition occurs when two or more threads try to modify a shared resource simultaneously, leading to inconsistent results.


class Counter {
    int count = 0;

    void increment() {
        count++;
    }
}

If multiple threads call increment() at the same time, the final count may be wrong.


21. What is synchronization in Java?

Synchronization is the mechanism that allows only one thread to access a shared resource at a time — preventing race conditions.


synchronized void increment() {
    count++;
}

22. What is a critical section?

A critical section is a part of the code that accesses shared resources and must not be executed by more than one thread simultaneously.


23. Difference between synchronized method and synchronized block

TypeDescription
Synchronized MethodLocks the entire method.
Synchronized BlockLocks only a specific section of code.

// Synchronized block example
void increment() {
    synchronized(this) {
        count++;
    }
}

24. What is Thread.currentThread()?

Thread.currentThread() returns a reference to the currently executing thread object.


System.out.println(Thread.currentThread().getName());

25. What is the join() method used for?

join() is used to make one thread wait for another thread to complete before continuing.


Thread t1 = new Thread(() -> {
    for (int i = 1; i <= 3; i++) {
        System.out.println("Child Thread " + i);
    }
});

t1.start();
t1.join(); // main thread waits

System.out.println("Main thread resumes after t1 finishes");

Conclusion

Multithreading is a crucial concept for writing efficient and high-performance Java applications.

Understanding thread creation, synchronization, and lifecycle helps you build concurrent programs safely and effectively.

In interviews, always back up your theoretical answers with small code examples — it shows practical understanding.



Next Read:
👉 Top Advance Multithreading Interview Questions with detailed answers
👉 Top 25 Advance Multithreading Interview Questions with detailed answers