Multithreading in Java — Java Technical Interview Questions & Answers

Multithreading in Java

Multithreading in Java

  • Multithreading means one program can run several paths of work at the same time. A thread is a lightweight unit of execution inside a process. Create with a Thread subclass or Runnable, then call start().
  • start() asks the JVM to begin a new thread. run() is only the work body. If you call run() yourself, no new thread is scheduled — that is the classic trap. Why threads: keep a server responsive, do background work, use more than one core.
  • Shared data needs care (synchronization) or results become wrong. Interview line: thread = path of execution; start vs run; shared data needs sync.
  • Let's take this on the board with one tiny Main class — no extra files. Multithreading in Java — start() schedules the thread; main also prints — order may vary. Start from main, go line by line, and stop at each print. That output is the proof for Multithreading.
  main
    │ start()
    ▼
  worker → run()
    │
    └── join() waits

Technical Interview Tip: start() vs run() is a classic trap question.

Code Examples for Multithreading in Java

Example

// Thread demo
public class Main {
  public static void main(String[] args) {
    Thread t = new Thread(() -> System.out.println("Hi from thread"));
    t.start();
    System.out.println("Hi from main");
  }
}

Multithreading in Java — start() schedules the thread; main also prints — order may vary.

How to Explain Multithreading in Java to an Interviewer

What is a thread?

A path of execution Inside a process

start() vs run()?

start() schedules a new thread run() is just the work

Why synchronize?

Shared data can become wrong