class MyTask implements Runnable { public static int teller = 0; private final int id; public MyTask() { teller++; id = teller; } public void run() { for (int i = 1; i < 5000; i++) if (i % 1000 == 0) System.out.printf("Hello for the %d-th time!\nThis is thread number %d\n", i / 1000, id); } }