这里我有一个函数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)
{
}
}