Sitemap

Member-only story

Difference Between Runnable and Thread in Java

4 min readApr 6, 2025

🔒 This is a Medium member-only article. If you’re not a Medium member, you can read the full article for free on my blog: Difference between Runnable and Thread in Java.

In Java, multithreading is one of the core features that allows programs to perform multiple tasks simultaneously. When learning how to create threads, you’ll encounter two commonly used approaches:

  • Extending the Thread class
  • Implementing the Runnable interface

Both are used to define and execute tasks in separate threads, but they are not the same and serve different design purposes.

In this article, we will explain the difference between Runnable and Thread in Java, their advantages and disadvantages, and when to use one over the other — with examples and a clear comparison table.

Introduction to Threading in Java

Multithreading in Java allows multiple parts of a program to execute concurrently, making applications more responsive and efficient — especially for tasks like I/O operations, file processing, or background services.

Java provides two main ways to create threads:

  1. By extending the Thread class
  2. By implementing the Runnable interface

Let’s look at both.

What is Thread in Java?

Thread is a class in the java.lang package that represents a single thread of execution. You can create a thread by extending this class and overriding the run() method.

Example: Using Thread Class

class MyThread extends Thread {
public void run() {
System.out.println("Thread is running: " + Thread.currentThread().getName());
}
}

public class ThreadExample {
public static void main(String[] args) {
MyThread t1 = new MyThread();
t1.start(); // Starts a new thread
}
}

Output:

Thread is running: Thread-0

Key Points:

  • You extend the Thread class.
  • You override the run() method to define the thread’s task.
  • You call start() to begin the thread’s execution.

What is Runnable in Java?

--

--

No responses yet