As you can see, the code looks totally fine. But, actually, the problem is when I'm running it in my browser (Chrome) the seconds are correct. However, at times it actually skips a second, which is messing up parts of my application.
When I use System.nanoSeconds() I've noticed every time I get the current time (using an auto refresher - refresh every second) a few of the milli digits are actually increasing every seconds the auto refresh kicks in. Eventually, the servlet skips a second.
Any tips please? The code you see is the only code that's actually running.
Oli Wurster wrote:Have you debugged the servlet? Is there a new GET request every 1 second? I think that it could be a network or client problem. The auto refresher probably is some kind of client script that refreshes the page every interval. It could also be a problem on the auto refresher.
Thanks for the reply. There's a get request every second. This is running on my localhost machine (until deployment).
Do you think there can be a performance hit when running GlassFish on a localhost machine? Rather than a dedicated
server? Personally, I think its because my dev-machine. Its kinda slow and crap to run GlassFish
I hope that helps.
phillip nash wrote:There's a get request every second.
Have you confirmed that this is happening precisely once per second? And how precisely is it happening? And have you confirmed that there are no network delays which reduce the precision of that measurement? And no delays in your server either?
You suggest that there's a problem in your application if a certain piece of code doesn't run exactly once per second. I wouldn't choose sending a GET request from a client system to fulfil that requirement -- but perhaps I didn't understand your requirement.