标题:如何解决秒表精度?
取消只看楼主
li2131538
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-8-3
 问题点数:0 回复次数:0 
如何解决秒表精度?
import java.awt.*;
import java.awt.event.*;
class Demo extends Canvas implements Runnable
{
int f1=0,f2=0,m1=0,m2=0,hm1=0,hm2=0;//f1,f2,m1,m2,hm1,hm2分别用来当00:00:00 f1f2:m1m2:hm1hm2
static Demo demo; //公共Demo
int pi=0; //用来当开关
Frame frame = new Frame();
public void ini()
{

setSize(800,600);
frame.setSize(800,600);
frame.add(this);
frame.setVisible(true);
this.addMouseListener(
new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
pi=(pi+1)%2;
if(pi==1)
{
Thread tt = new Thread(demo);
tt.setName("li");
tt.setPriority(1);
tt.start();
}
}
}
);
}
public void run()
{
while(pi!=0)
{
try
{
Thread.sleep(10);
}
catch(Exception e)
{
}
System.out.println(f1+""+f2+":"+m1+""+m2+":"+hm1+""+hm2);
++hm2;
if(hm2==10)
{
++hm1;
hm2=0;
if(hm1==10)
{
++m2;
hm1=0;
if(m2==10)
{
++m1;
m2=0;
if(m1==6)
{
++f2;
m1=0;
if(f2==10)
{
++f1;
f2=0;
if(f1==6)
{
f1=0;
}
}
}
}
}
}
}
}
public static void main(String[] ager)
{
demo = new Demo();
demo.ini();
}
}
搜索更多相关主题的帖子: 精度 秒表 
2007-08-03 00:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-160020-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.885666 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved