【发布时间】:2012-01-28 23:38:22
【问题描述】:
这里我有一个 checkupdate() 功能,其中我的应用程序检查可供用户使用的更新,所以我需要在服务器处于请求状态时显示两个进度对话框(检查过程),另一个在同步过程正在进行时显示两个进程在应用程序的负载上完成。 现在的问题是我无法显示这两个进度对话框,这里只有第一个线程检查更新正在运行并且应用程序被终止。 等待您的宝贵答案。
public void CheckUpdate()
{
//----------------Process of checking the updates--------------------------
try
{
progressDialog = ProgressDialog.show(this, "Wait", "Checking update...", false, true);
Thread thr1 = new Thread()
{
public void run()
{
int Flag = call.CheckUserUpdate(UsrId);
Update = Flag;
progressDialog.dismiss();
//stop();
interrupt();
}
};
thr1.start();
}
catch(final Exception e)
{
}
//---------------Process of Synchronization----------------------------------------------
try
{
progressDialog1 = ProgressDialog.show(this, "Wait", "Synchronizing...", false, true);
Thread thr2 = new Thread()
{
public void run()
{
if(Update == 1)
{
SyncData();
final int UpdateFlag = 1;
call.UpdateUserUpdate(UsrId, UpdateFlag);
progressDialog1.dismiss();
}
else
{
progressDialog1.dismiss();
}
progressDialog1.dismiss();
}
};
thr2.start();
}
catch(final Exception e)
{
}
}
【问题讨论】:
标签: java android multithreading thread-safety threadpool