Here is one using a thread (I inflated the sleep time to account for fluctuations in system speed). I couldn't think of a way to get rid of the try / catch:
public class Counter extends Thread{
private int cnt;
public Counter(){
this.cnt = 0;
}
private void increment(){
System.out.println(cnt++);
try{
Thread.sleep(1000);
}catch(Exception e){}
increment();
}
public void run(){
increment();
}
public static void main(String[] args) throws Exception{
Counter cntr = new Counter();
cntr.start();
cntr.join(100000);
cntr.interrupt();
System.exit(0);
}
}