Implement the Runnable interface for classes whose instances are intended to be executed by a thread.
Source Code
class HelloRunnable implements Runnable {
public void run() {
System.out.println("Hello from a thread!");
}
}
public class TestRunnable {
public static void main(String[] args) {
(new Thread(new HelloRunnable())).start();
}
}