class StopClock extends Thread
{
private int hh=0;
private int mm=0;
private int ss=0;
public int getHr()
{
return hh;
}
public int getMn()
{
return mm;
}
public int getSs()
{
return ss;
}
public void run()
{
for(;;)
{
try
{
Thread.sleep(1000);
}
catch(InterruptedException ie)
{
}
ss++;
mm+=ss/60;
ss%=60;
hh+=mm/60;
mm%=60;
hh%=24;
}
}
}
{
private int hh=0;
private int mm=0;
private int ss=0;
public int getHr()
{
return hh;
}
public int getMn()
{
return mm;
}
public int getSs()
{
return ss;
}
public void run()
{
for(;;)
{
try
{
Thread.sleep(1000);
}
catch(InterruptedException ie)
{
}
ss++;
mm+=ss/60;
ss%=60;
hh+=mm/60;
mm%=60;
hh%=24;
}
}
}
No comments:
Post a Comment