여기 checkupdate() 함수는 사용자가 내 응용 프로그램을 사용할 수 있는지 확인합니다. 그래서 두 개의 progressdialog를 표시해야합니다. 서버가 요청 (체크 프로세스) 중이며 동기화 프로세스가 진행 중이고 프로세스가 진행 중일 때 응용 프로그램의로드에 완료. 이제는 두 개의 진행률 대화 상자를 표시 할 수 없으므로 스레드 업데이트 확인 중 첫 번째 메시지 만 이 실행되고 응용 프로그램이 종료됩니다. 귀중한 답변을 기다리고 있습니다.하나의 함수에서 두 개의 스레드를 사용하는 방법은 무엇입니까?
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)
{
}
}