public class Test { public static void main(String[] args) { long count = 0; long lastUpdate = System.nanoTime(); while(true) { if (System.nanoTime() - lastUpdate > 1000000000L) { // Print out count roughly every second System.out.println(count); count = 0; lastUpdate = System.nanoTime(); } try { Thread.sleep(16); // 60 updates per second } catch (InterruptedException ex) { // do nothing } count++; } } }