You don't really need a thread. Just write a program which doesn't exit.public class HelloWorldForever {
public static void main(String[] args) {
while (true) {
System.out.println("Hello World");
}
}
}
But if you want a threadpublic class HelloWorldForeverThread {
public static void main(String[] args) {
Thread t = new Thread(new Runnable() {
public void run() {
while (true) { System.out.println("Hello World"); }
}
});
t.start();
}
}