Well, then how should the fps be higher than 1000ms/25ms=40? If you don't want 100% load on the core that executes the loop (the rendering will take place on another core if available), the sleep will always limit your fps to 1000ms/sleepTime. You may want to adjust the sleep time according to the time the frame takes to be processed, i.e. measure the time taken from buffer.clear to canvas.repaint() with a high accuracy timer (i.e. not with currentTimeMillis() but nanoTime() or something) and subtract that from 25. That way, you'll get a constant 40fps in that loop regardless of how long the processing takes (given that it doesn't take longer than 25ms). That's what i'm doing in my game to limit the fps to 75fps.
The fps-example uses the OpenGL renderer. That renderer uses (unless configured otherwise, which no one ever did except for myself as far as i know...) one thread only. The AWTGLRenderer uses two. One is your loop-executing thread and one is the rendering thread (which is in fact the AWT event dispatch thread). If you want to measure rendering time/fps, you can't do it in the loop like the fps-example does it. It's just not accurate, because it may happen that the loop calculates 2 frames but the render thread only manages to process one in that time. There is the IPaintListener interface. You can implement it in your main class and put the fps-counter-code in the finishedPainting()-method. That should give you correct fps.