Seconds from Thread
Hello. I am trying to make a timer of sorts that times seconds and minutes. the only problem is the thread I created isn't timing exact seconds like it should. I know that a thread is supposed to sleep for a certain amount ofmiliseconds so why won't it come out even? Making the thread sleep for 16 "miliseconds" is the closest I can get to the real thing but It's still slightly too slow. 17 is too fast. Any ideas?
publicvoid run()
{
while(true)
{
doStuff();
}
}
publicvoid doStuff()
{
try
{
thread.sleep(16);
}
catch(InterruptedException e){}
if(timingcycle == 2)
{
miliseconds++;
if(miliseconds == 60)
{
seconds++;
miliseconds = 0;
if(seconds == 60)
{
minutes++;
seconds = 0;
}
}
}
repaint();
}

