Skip to content
C

Multithreading Interview Questions

A process is an independent running program with its own memory space. A thread is a smaller unit of execution within a process, and multiple threads within the same process share that process's memory.


Q1. What is the difference between a process and a thread? A process is an independent running program with its own memory space. A thread is a smaller unit of execution within a process, and multiple threads within the same process share that process's memory.

Q2. What is the difference between extending `Thread` and implementing `Runnable`? Extending Thread uses up your one allowed class inheritance in Java. Implementing Runnable keeps your class free to extend some other class as well, making it generally the more flexible choice.

Q3. What is synchronization, and why is it needed? Synchronization ensures only one thread can access a particular block of code or shared resource at a time, preventing data corruption when multiple threads try to modify shared data simultaneously.

Q4. What is a deadlock? A deadlock occurs when two or more threads are stuck waiting indefinitely for each other to release a resource, causing the program to freeze for those threads.

Q5. What is the difference between `Runnable` and `Callable`? Runnable's run() method returns nothing and cannot throw a checked exception. Callable's call() method can return a result and can throw checked exceptions.

Q6. What does the `join()` method do? It makes the calling thread wait until the thread it's called on has finished executing, before continuing further.

Key Points to Remember

  • Multithreading questions often test conceptual understanding through short scenario-based questions, like "what happens if two threads do X at the same time?"
  • Be ready to explain the difference between sleep() and wait() if asked, even though wait() wasn't covered in earlier modules — it's a common follow-up.
  • Practice explaining deadlock with a simple, clear real-life analogy, since interviewers often ask for one.