具有计时器的可执行jar [英] executable jars with timers

查看:122
本文介绍了具有计时器的可执行jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个程序,有两个运行小动画的计时器。最初timerX运行在5ms,timerY运行了1ms。我将程序导出到一个可执行的jar文件,一切正常。然后我将jar发送到另一台运行相同规格的计算机,再也没有问题。但是,我决定加快timerX,所以我把这个定时器改为1ms运行,保存并导出文件。从我的桌面,这个新文件运行良好,但是当传递给另一台计算机时,与前一个文件没有任何变化。在我将其重新发送到可执行的jar文件之前,是否有需要在eclipse中执行的操作?另外为什么它的运行从我的桌面,但不是在另一台电脑 - 第二个定时器也设置在1ms运行同样快的两个实例。

解决方案

定时精度 所示时钟分辨率取决于主机平台和操作系统。虽然 javax.swing.Timer 将默认合并事件,定时器线程将在这么短的时间(高频率)下快速饱和。您可能需要在旧系统上进行补偿。


I wrote a program with two timers running small animations. Originally timerX was running at 5ms and timerY was running a 1ms. I exported the program to an executable jar file and everything worked fine. I then sent the jar to another computer running the same specs and again there were no problems. However, I decided to speed up timerX, so I changed this timer to run at 1ms, ran, saved and exported the file. From my desktop this new file ran perfectly but when passing it to the other computer there was no change from the previous one. Is there something I need to do in eclipse before I resend it to the executable jar file? Also why is it running fine from my desktop but not on the other computer - the second timer which is also set at 1ms runs equally fast in both instances.

解决方案

As shown in Timer accuracy, clock resolution depends on the host platform and operating system. Although javax.swing.Timer will coalesce events by default, the timer thread will tend to saturate quickly with such a short period (high frequency). You may need to compensate on older systems.

这篇关于具有计时器的可执行jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆