public class SpinOnGetTime { public static void main( String[] args ) { long prev_time = System.currentTimeMillis(); int count_times_through = 1; while ( true ) { long curr_time = System.currentTimeMillis(); if ( curr_time - prev_time > 250 ) { System.out.println( count_times_through + " "); ++count_times_through; prev_time = curr_time; } } } }