# Thread vs Runnable and the Thread Lifecycle

> How do you create a thread in Java? Thread vs Runnable, start() vs run(), and what are the thread states?

Canonical: https://www.internhack.in/learn/interview/java-interview/java-thread-vs-runnable
Last updated: 2026-11-28

Difficulty: Beginner

## Question

How do you create a thread in Java? Thread vs Runnable, start() vs run(), and what are the thread states?

## Answer

Multithreading questions are a guaranteed part of Java interviews, and this is the entry point. Let me explain it like a kitchen: a thread is a cook, and a Runnable is the recipe card. Do you want to hire a special cook with the recipe tattooed on his arm, or keep the recipe separate so any cook can follow it? That is the whole Thread versus Runnable debate.

There are two classic ways to create a thread. First, extend the Thread class and override run. Second, implement the Runnable interface, which has a single method run, and pass the object to a Thread constructor. In modern code, you write the Runnable as a lambda: new Thread(() -> doWork()). There is a third option, Callable, which is like Runnable but returns a value and can throw checked exceptions; you submit it to an ExecutorService and get a Future.

Which should you prefer? Runnable, nearly always. Java has single inheritance, so extending Thread uses up your only superclass slot. Runnable separates the task (what to run) from the mechanism (how to run it), which lets you run the same task on a plain thread, a thread pool or a scheduled executor. Extending Thread is only justified if you actually want to change thread behaviour itself, which is rare.

Now the classic trap: start versus run. Calling start asks the JVM to create a new OS-level thread, and that new thread then executes run. Calling run directly is just an ordinary method call executing on the current thread; no new thread is created. That is why printing Thread.currentThread().getName() inside run shows main if you call run yourself. Also, calling start twice on the same thread throws IllegalThreadStateException, because a thread can only be started once.

The lifecycle has six states defined in Thread.State. NEW: created but start not called. RUNNABLE: ready or running (Java does not separate ready and running). BLOCKED: waiting to acquire a monitor lock to enter a synchronized block. WAITING: waiting indefinitely for another thread, after wait, join or LockSupport.park with no timeout. TIMED_WAITING: waiting with a timeout, such as sleep, wait(ms) or join(ms). TERMINATED: run has completed or ended with an exception.

Other essential methods. join makes the calling thread wait until the target thread finishes. sleep pauses the current thread without releasing any locks it holds. yield is a scheduler hint. interrupt sets the interrupt flag and wakes a thread from sleep or wait with InterruptedException; interruption is a cooperative cancellation mechanism, not a kill. The deprecated stop should never be used.

Also mention daemon threads. A daemon thread, set before start with setDaemon(true), does not keep the JVM alive; the JVM exits when only daemon threads remain. Garbage collector threads are daemons. The JVM's main thread and user threads are non-daemon.

Finally, for real applications you rarely create raw threads. Creating a thread per task is costly in memory and context switching, so use an ExecutorService thread pool. Since Java 21, virtual threads (Thread.ofVirtual or Executors.newVirtualThreadPerTaskExecutor) make thread-per-task cheap for blocking I/O workloads, and you can mention them as a modern answer.

## Code examples

### start() vs run()

```
public class ThreadDemo {
    public static void main(String[] args) throws InterruptedException {
        Runnable task = () ->
            System.out.println("Running in " + Thread.currentThread().getName());

        Thread t = new Thread(task, "worker-1");
        t.run();
        t.start();
        t.join();

        System.out.println(t.getState());
        try {
            t.start();
        } catch (IllegalThreadStateException e) {
            System.out.println("cannot restart");
        }
    }
}
```

run executes on the main thread; start executes on the new worker-1 thread. After join the state is TERMINATED and a thread cannot be started again.

## Key points

- Prefer Runnable (or Callable) over extending Thread.
- start creates a new thread; run is just a method call on the current thread.
- A thread can be started only once.
- States: NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING, TERMINATED.
- Use thread pools or virtual threads instead of raw threads in production.

## Common follow-up questions

- What is the difference between Runnable and Callable?
- What does join do?
- What is a daemon thread?
- How do you stop a thread properly?

## Interview tips

- Explain start versus run with the thread name output; it is the most common trap.
- Mention that sleep keeps holding locks while wait releases them, which sets up the next question.

## Concepts covered

Thread, Runnable, Callable, start vs run, Thread Lifecycle

Previous: [Garbage Collection Basics and GC Roots](https://www.internhack.in/learn/interview/java-interview/java-garbage-collection-basics) · Next: [synchronized vs volatile: Visibility, Atomicity and Ordering](https://www.internhack.in/learn/interview/java-interview/java-synchronized-volatile) · [All of Core Java & Collections](https://www.internhack.in/learn/interview/java-interview)

## More Core Java & Collections questions

- [wait(), notify() and the Producer-Consumer Pattern](https://www.internhack.in/learn/interview/java-interview/java-wait-notify)
- [Deadlock: Conditions, Detection and Prevention](https://www.internhack.in/learn/interview/java-interview/java-deadlock)
- [ExecutorService, Thread Pools and Future](https://www.internhack.in/learn/interview/java-interview/java-executorservice-thread-pools)
- [Lambdas, Functional Interfaces and Method References](https://www.internhack.in/learn/interview/java-interview/java-lambdas-functional-interfaces)
- [Streams API: Pipelines, Laziness and Collectors](https://www.internhack.in/learn/interview/java-interview/java-streams-api)
- [Optional: Purpose, Usage and Anti-Patterns](https://www.internhack.in/learn/interview/java-interview/java-optional)

## Related

- [Learn](https://www.internhack.in/learn)
- [Interview Prep](https://www.internhack.in/learn/interview)
- [Core Java & Collections](https://www.internhack.in/learn/interview/java-interview)
