行,所以我得到这个设置: 一个MIDletJ2ME的MIDlet双线程未能回调
Gui extends Midlet{
private static Gui instance;
protected void startApp() {
Display.getDisplay(this).setCurrent(MyForm.getInstance());
}
private static final Logger log = LoggerFactory.getLogger();
public static Datacheck getInstance() {
return instance;
}
public Gui() {
// Configure logging
}
protected void startApp() {
instance = this;
Display.getDisplay(this).setCurrent(MyForm.getInstance());
}
protected void pauseApp() {
}
protected void destroyApp(boolean bool) {
// Shutdown Microlog gracefully
LoggerFactory.shutdown();
notifyDestroyed();
}
public static void log(Level level, String message) {
log.log(level, message);
}
public void requestScreen(Form screen) {
log.info("request screen called");
Display.getDisplay(this).setCurrent(screen);
}
}
形式
MyForm extends Form{
private static MyForm instance;
public static MyForm getInstance() {
if (instance == null) {
instance = new MyForm();
}
return instance;
}
private Form(){
//start task
new Timer().scheduleAtFixedRate(new PollingService(CallsDialog.getInstance()), 0, UPDATE_INTERVAL);
//add gui elements ....
}
private void updateForm() {
//never gets executed
}
}
和线程
MyThread implements Runnable{
private MyForm handle;
public PollingService(MyForm handle) {
this.handle = handle;
}
public void run() {
handle.updateForm();
}
}
所以该MIDlet启动,将其表单设置为MyForm的实例 然后myform创建一个新线程 这个线程应该调用myForm会的功能每5秒
这是真实的东西非常简化的例子,所以请,当我从执行的方法“不改变线程设计
现在MyForm“类 它不执行 我没有得到任何错误
任何人都知道我在做什么错?
编辑 改变,所以没有创建的线程(已被TimerTask的完成)
尝试把SOP和打印stacktrace在catch中,尝试调试,代码似乎没问题。 – 2010-11-15 07:00:48