public class MyTask implements Runnable { public void run() { for (int i = 1; i <= 5000; i++) { if (i % 1000 == 0) { System.out.println("Hello for the " + i/1000 + "th time!"); } } } }