GWT中的Java定时器 [英] Java Timer in GWT
本文介绍了GWT中的Java定时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
定时器计时器=新的计时器();
timer.schedule(
new TimerTask(){
public void run(){
//一些代码
}
}
, 5000);
但是当试图编译时,我得到:
没有源代码可用于类型 java.util.Timer中
;你忘了
来继承一个必需的模块吗?
我能做些什么来解决这个错误?
解决方案
/Timer.htmlrel =nofollow> libgdx 计时器
基础设施,以安排将来运行的工作:
定时器t =新的定时器();
t.scheduleTask(new Timer.Task(){
public void run(){/ * some code * /}
}),/ *请注意,libgdx使用float秒,而不是整数毫秒:* / 5);
通过这种方式,您可以在独立于平台的代码中安排计时器。 (GWT特定的解决方案只能在项目的平台相关部分中工作。)
I'm trying to have a Java Timer in my EntryPoint:
Timer timer = new Timer();
timer.schedule(
new TimerTask() {
public void run() {
//some code
}
}
, 5000);
But when trying to compile this I got:
No source code is available for type java.util.Timer
; did you forget
to inherit a required module?
What can I do to fix this error?
解决方案
If you're using Libgdx, you can use the libgdx Timer
infrastructure to schedule work to run in the future:
Timer t = new Timer();
t.scheduleTask(new Timer.Task() {
public void run() { /* some code */ }
}), /* Note that libgdx uses float seconds, not integer milliseconds: */ 5);
This way you can schedule the timer in your platform independent code. (The GWT-specific solution will only work in the platform dependent part of your project.)
这篇关于GWT中的Java定时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文