import java.util.*;
public class RepeaterThreadTest implements Runnable {
public RepeaterThreadTest() {
Thread t = new Thread(this);
t.start();
System.out.println("Thread Başlatıldı");
}
public void run() {
// while(true) ifadesi ile thread devamlı çalışması sağlanmaktadır.
while (true) {
try {
// içinde bulunan thread 1 saniye bekletilmektedir.
Thread.sleep(1000);
System.out.println("Thread: " + new Date());
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
RepeaterThreadTest t = new RepeaterThreadTest();
}
}
Dosyayı İndir