具有计时器的可执行jar [英] executable jars with timers
问题描述
如 定时精度 所示时钟分辨率取决于主机平台和操作系统。虽然 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屋!