Multithreading Lwuit J2ME中的等待屏幕
我只想在解析Lwuit J2ME应用程序中的一些Xml时显示一个加载屏幕。 我看到有很多例子,比如滑块和量规,我发现了这个简单的代码,但我不知道在解析操作时如何显示对话框。 如果我使用dialog.showDialog();它将阻止用户界面Multithreading Lwuit J2ME中的等待屏幕,multithreading,java-me,loading,lwuit,Multithreading,Java Me,Loading,Lwuit,我只想在解析Lwuit J2ME应用程序中的一些Xml时显示一个加载屏幕。 我看到有很多例子,比如滑块和量规,我发现了这个简单的代码,但我不知道在解析操作时如何显示对话框。 如果我使用dialog.showDialog();它将阻止用户界面 passenger p = new passenger(); p.start(); synchronized (p) { System.out.println("passenger is waiting for the bus ");
passenger p = new passenger();
p.start();
synchronized (p) {
System.out.println("passenger is waiting for the bus ");
try {
p.wait();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.out.println("passenger got notification");
// I think that i must use the loading thing here but i don't know
// what to do.
}
System.out.println("after "+p.total+" time");
class passenger extends Thread {
int total = 0;
public void run() {
synchronized (this) {
System.out.println("wait .... ");
for (int i = 0; i <= 3000; i++){
total = total + i;
System.out.println(total+"");
}
System.out.println("passenger is given notification call");
notify();
}
}
乘客p=新乘客();
p、 start();
同步(p){
System.out.println(“乘客正在等公共汽车”);
试一试{
p、 等待();
}捕获(中断异常例外){
例如printStackTrace();
}
System.out.println(“乘客收到通知”);
//我想我必须在这里使用装载设备,但我不知道
//怎么办。
}
系统输出打印项次(“在“+p.total+”时间之后”);
二等舱乘客延长线{
int-total=0;
公开募捐{
已同步(此){
System.out.println(“等待…”);
对于(int i=0;i您需要在后台线程中进行解析,然后在解析完成后处理该对话框。谢谢,您能否告诉我是否可以使用上面的任何代码来帮助我完成此操作。或者有其他方法实现等待屏幕?您正在调用wait()在EDT上,这否定了打开新线程的想法。您需要在显示等待对话框后释放EDT。