Scrivio Interview library
CodingFoundations5 min read · updated 12 November 2026

What is the difference in behaviour here?

Java
Thread t = new Thread(() -> System.out.println(Thread.currentThread().getName()));
t.run();
t.start();

t.run() is an ordinary method call: the lambda runs on the calling thread, so it prints the caller's name, for example main, and no new thread exists. t.start() asks the JVM to create a new thread, which then calls run() itself, so the lambda prints the new thread's name, such as Thread-0. run() can be called any number of times like any method, while start() works only once per Thread object. Calling run() instead of start() is a common bug that silently removes all concurrency.

Why this question is asked

This question is short, but the bug it describes is real and surprisingly common in code reviews and take-home tests: code that looks concurrent, uses Thread objects, and runs everything sequentially on one thread. The program still produces correct output, just slowly, so nothing fails loudly. Interviewers ask it because the answer shows whether we understand that a Thread object and a thread of execution are different things. In this answer, we will recap what a Thread object is, trace both calls, see why start works only once, and look at how the bug shows up and how to avoid it.

1A Quick Recap: A Thread Object Is Not a Thread

new Thread(runnable) creates an ordinary Java object that describes a thread: its name, its priority, whether it is a daemon, and the Runnable it should execute. At this point nothing runs concurrently; the object is in state NEW.

The actual thread of execution, with its own stack, scheduled by the operating system, only comes into existence when start() is called. start() is the bridge between the object and the JVM. run() is just the method that holds the work; it belongs to the Runnable interface, and Thread implements it by calling the Runnable it was given.

2Tracing Both Calls

Here is the code from the question, with what each line prints when it is run from a main method.

Java
Thread t = new Thread(() -> System.out.println(Thread.currentThread().getName()));
t.run(); // main : a plain method call on the current thread
t.start(); // Thread-0 : a new thread is created and it calls run()
Step throughrun() versus start()
mainThread t objectnew thread Thread-0
t.run()
lambda runs on main, prints main
t.start()
JVM creates the thread
start() returns at once
calls run(), prints Thread-0

6 messages in order. Play them, or step through them one at a time.

t.run() behaves exactly like calling any method. The current thread, main, jumps into Thread.run(), which calls the lambda, which asks Thread.currentThread() for the running thread. That is still main, so it prints main. When the lambda finishes, run() returns and main continues to the next line. No concurrency happened at all.

t.start() is different. The JVM creates a new native thread, marks the Thread object as started, and returns to main immediately. Some moments later, the new thread begins executing, and the first thing it does is call t.run(). Inside the lambda, Thread.currentThread() is now the new thread, whose default name is Thread- followed by a number, Thread-0 for the first unnamed thread in this program. The exact moment it prints is up to the scheduler, so in a larger program its output can interleave with main's.

3Run() Any Number of Times, start() Only Once

Because run() is a plain method, we can call it repeatedly, and each call executes the work again on the caller's thread. start() is guarded. A Thread object represents one execution, and once it has been started, calling start() again throws IllegalThreadStateException, whether the thread is still running or has already finished.

Java
Thread t = new Thread(() -> System.out.println(Thread.currentThread().getName()));
t.run(); // main
t.run(); // main
t.start(); // Thread-0
t.join();
t.start(); // IllegalThreadStateException

If we want to run the same task on a new thread again, we create a new Thread, or better, submit the Runnable to an ExecutorService, which reuses a pool of threads. Calling run() after the thread has finished is technically possible, but what it does is a detail that differs between JDK versions, so check your version and do not rely on it.

4How the Bug Shows Up

The classic form is a loop that is meant to process work in parallel.

Java
List<Thread> workers = new ArrayList<>();
for (Path file : files) {
Thread w = new Thread(() -> process(file));
workers.add(w);
w.run(); // bug: processes each file on main, one after another
}
for (Thread w : workers) w.join(); // returns at once: none of them was ever started
// 10 files x 2 s each: takes 20 s instead of about 2 s

Everything produces the right result, so tests pass, but the total time is the sum of all tasks instead of roughly the longest one. Logging Thread.currentThread().getName() inside the task, or watching a thread dump, shows the problem immediately: every task runs on main.

The fix is to call start(), and in modern code to avoid managing raw threads at all. An ExecutorService, for example Executors.newVirtualThreadPerTaskExecutor() on Java 21 or later, makes the mistake impossible because we submit tasks rather than calling methods on threads, and it also gives us Futures to collect results and exceptions.

5Follow-up questions

Why does Thread have a public run() method at all?

Because Thread implements Runnable, and Runnable requires a public run(). Early Java also encouraged subclassing Thread and overriding run(). The design makes the mistake possible; passing a Runnable to an executor is the cleaner model.

What happens to an exception thrown in run() in each case?

With t.run(), the exception propagates to the caller like from any method. With t.start(), it happens on the new thread, terminates that thread, and goes to the thread's uncaught exception handler, which by default prints the stack trace; the caller never sees it unless it uses an executor and a Future.

Can the output order of start() be relied on?

No. After start() returns, the new thread runs when the scheduler decides, so its output may appear before or after main's next lines. If order matters, coordinate explicitly with join(), a latch or a Future.

6Conclusion

In this answer, we saw that t.run() is a plain method call that executes the lambda on the calling thread, printing main, while t.start() creates a new thread that calls run() itself, printing a name such as Thread-0. run() can be called any number of times, but start() only once per Thread object, after which it throws IllegalThreadStateException. Calling run() instead of start() is a quiet but common bug that removes all concurrency, best avoided by submitting tasks to an ExecutorService.

What to say in the interviewAbout 100 seconds aloud

Open with

The difference is which thread executes the lambda. t.run() is just a normal method call. Thread's run method calls the Runnable we passed in, on the current thread, so Thread.currentThread is still main and it prints main.

Then, if they want more

No new thread is created, and nothing happens concurrently. t.start() is what actually creates a thread. The JVM creates a new native thread, start returns immediately to main, and then the new thread calls run on its own, so the lambda prints the new thread's name, something like Thread-0.

Also, since run is just a method, I can call it as many times as I want; start can only be called once per Thread object, and a second call throws IllegalThreadStateException, even after the thread finishes. If I need to run the task again on another thread, I create a new Thread or submit it to an executor.

Calling run instead of start is a classic bug because nothing fails: the code produces the right result but runs everything sequentially on the calling thread, so a loop that was meant to process ten files in parallel takes ten times as long, and any join calls return immediately because the threads were never started.

Logging the thread name inside the task exposes it straight away. In modern code I'd avoid raw threads and submit tasks to an ExecutorService, for example a virtual-thread-per-task executor, which makes this mistake impossible and gives me Futures for results and exceptions.

About this answer

Last updated
12 November 2026
Versions it names
Java 21
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is the difference in behaviour here?": https://scrivio-interview-library.netlify.app/java/threads/298e51c616/