Skip to content
On this page

Threads and Concurrency:

Java supports multithreading and concurrency to perform multiple tasks concurrently.

java
// Threads and concurrency
public class MyRunnable implements Runnable {
    @Override
    public void run() {
        System.out.println("Thread is running.");
    }
}

public class Main {
    public static void main(String[] args) {
        Thread thread = new Thread(new MyRunnable());
        thread.start(); // Start the thread
    }
}