// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class SleepLoop {
    private static void dosomething() throws InterruptedException {
        // simulate that it takes some time
        Thread.sleep(100);
    }
    public static void main(String[] args) throws InterruptedException {
        long t = System.currentTimeMillis();
        while(true) {
            dosomething();
            Thread.sleep(1000);
            long t2 = System.currentTimeMillis();
            System.out.printf("%5.3f seconds\n", (t2 - t)/1000.0);
            t = t2;
        }
    }
}
