ALL LESSONS Module 23

Multithreading and Concurrency

Apr 5, 2026 1 min read

Java Multithreading

Execute multiple threads concurrently for better performance.

Thread Creation

class MyThread extends Thread {
    public void run() {
        System.out.println("Thread running");
    }
}

class MyRunnable implements Runnable {
    public void run() {
        System.out.println("Runnable executing");
    }
}

// Usage
MyThread t1 = new MyThread();
t1.start();

Thread t2 = new Thread(new MyRunnable());
t2.start();

Key Points

  • Extend Thread or implement Runnable.
  • start() not run() to create new thread.
  • Runnable preferred (single inheritance).
  • Thread lifecycle: New, Runnable, Running, Blocked, Dead.

Need help with this lesson? Visit the Discussion Forum