sclass DoubleFPSCounter { new FPSCounter counter; volatile double value; synchronized void inc() { if (counter.secondsSinceStart() >= 1) { value = counter!; counter = new FPSCounter; } counter.inc(); } synchronized double get() { ret value; } synchronized toString { ret counter.isEmpty() ? "" : formatDoubleX(get(), 1) + " FPS"; } }