Basic Multithreading with Thread Class in Java


Extend the Thread class and override the run method to create a simple thread.

Source Code

class HelloThread extends Thread {
    public void run() {
        System.out.println("Hello from a thread!");
    }
}

public class TestThread {
    public static void main(String[] args) {
        (new HelloThread()).start();
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments