Java Interview Question

What is multithreading in Java?

Updated 2026-08-16 · Beginner friendly
Quick answer

Multithreading is running several threads at the same time within one program, where each thread is an independent path of execution. It lets an application do multiple things at once, such as downloading a file while keeping the interface responsive. In Java you create threads by extending Thread or implementing Runnable.

Key takeaways
  • Multithreading runs multiple threads within one program so work happens concurrently.
  • You create threads by extending Thread or implementing Runnable, often via an executor.
  • Shared data needs synchronisation to avoid race conditions and inconsistent state.

Why use threads

A single threaded program does one thing at a time. Threads let you use multiple CPU cores and keep an app responsive, for example handling many web requests together on a server.

Runnable task = () -> System.out.println("running on a thread");
Thread t = new Thread(task);
t.start();   // runs task on a new thread

The main challenge

When threads share data, they can interfere with each other, causing race conditions. Java offers tools like synchronized blocks, locks, and concurrent collections to coordinate access safely.

In the interview

Expect a follow up on thread safety. Mention race conditions and that you protect shared state with synchronized, locks, or thread safe classes like ConcurrentHashMap. Awareness of the risks matters more than memorising the API.

Frequently asked questions

What is a race condition?

It is when two threads access shared data at the same time and the result depends on timing, leading to unpredictable or wrong values.

What does the synchronized keyword do?

It lets only one thread at a time run a block or method on a given lock, which prevents concurrent access to shared data.

Want the full Java guide?

Read every Java concept with notes, diagrams, and code in one place. Track your progress as you go.

Open the Java guide All Java questions