private ProgressDialog progressDlg = null;
private DAResult error;
private boolean stopFromTarget = false;
-
+ private Boolean stopThreadCompleted = false;
public StopTraceManager(DAResult err, boolean stopFromTarget) {
this.error = err;
this.stopFromTarget = stopFromTarget;
}
});
}
-
+
@Override
public void run() {
// DAResult result = DAResult.SUCCESS;
DACommunicator.stopTrace();
}
setStageComplete(STAGE.SEND_STOPMSG);
-
- // stop clock
- Toolbar.INSTANCE.stopTimer();
- setStageComplete(STAGE.STOP_CLOCK);
-
- // stop replay timer
- ReplayManager.resetStopAlarm();
- setStageComplete(STAGE.STOP_REPLAY_TIMER);
-
- // stop screenshot timer
- ScreenshotTimer.stop();
- setStageComplete(STAGE.STOP_SCREENSHOT_TIMER);
-
- // stop update timer
- UpdateViewTimer.stop();
- setStageComplete(STAGE.STOP_UPDATE_TIMER);
-
+
+ Thread stopTimers = new Thread(new Runnable() {
+ public void run() {
+ // stop clock
+ try{
+ Toolbar.INSTANCE.stopTimer();
+ setStageComplete(STAGE.STOP_CLOCK);
+
+ // stop replay timer
+ ReplayManager.resetStopAlarm();
+ setStageComplete(STAGE.STOP_REPLAY_TIMER);
+
+ // stop screenshot timer
+ ScreenshotTimer.stop();
+ setStageComplete(STAGE.STOP_SCREENSHOT_TIMER);
+
+ // stop update timer
+ UpdateViewTimer.stop();
+ setStageComplete(STAGE.STOP_UPDATE_TIMER);
+ }
+ catch(InterruptedException e){
+ Logger.debug(); // for new line
+ Logger.debug("Interrupt occurred while stopTimers");
+ }
+ }
+ });
+
+ stopTimers.start();
+
// if error code equals with canceling then stop threads by force
if (error.equals(DAResult.ErrorCode.ERR_BY_USER_CANCEL)) {
- // stop data channel
- DataChannelThread.getInstance().stopForced();
- setStageComplete(STAGE.STOP_DATATHREAD);
-
- // stop message parser
- MessageParser.getInstance().stopForced();
- setStageComplete(STAGE.STOP_MESSAGEPARSER);
-
- // stop log parser
- LogParser.getInstance().stopForced();
- setStageComplete(STAGE.STOP_LOGPARSER);
-
- // stop page data manager
- DataManagerRegistry.stopThreadsForced();
- setStageComplete(STAGE.STOP_PAGEMANAGER);
-
- // stop other db inserters
- CallStackInserter.getInstance().stopForced();
- setStageComplete(STAGE.STOP_CALLSTACK_INSERTER);
+ Thread stopForcedThread = new Thread(new Runnable() {
+ public void run() {
+ synchronized(stopThreadCompleted){
+ stopThreadCompleted=false;
+ }
+ // stop data channel
+ DataChannelThread.getInstance().stopForced();
+ // stop message parser
+ MessageParser.getInstance().stopForced();
+ // stop log parser
+ LogParser.getInstance().stopForced();
+ // stop page data manager
+ DataManagerRegistry.stopThreadsForced();
+ // stop other db inserters
+ CallStackInserter.getInstance().stopForced();
+ synchronized(stopThreadCompleted){
+ stopThreadCompleted=true;
+ }
+ }
+ });
+
+ stopForcedThread.start();
+ setStageComplete(STAGE.STOP_DATATHREADS);
+
} else {
- // stop data channel
- DataChannelThread.getInstance().stopNormal();
- setStageComplete(STAGE.STOP_DATATHREAD);
-
- // stop message parser
- MessageParser.getInstance().stopNormal();
- setStageComplete(STAGE.STOP_MESSAGEPARSER);
-
- // stop log parser
- LogParser.getInstance().stopNormal();
- setStageComplete(STAGE.STOP_LOGPARSER);
-
- // stop page data manager
- DataManagerRegistry.stopThreadsNormal();
- setStageComplete(STAGE.STOP_PAGEMANAGER);
-
- // stop other db inserters
- CallStackInserter.getInstance().stopNormal();
-
+
+ Thread stopNormalThread = new Thread(new Runnable() {
+ public void run() {
+ synchronized(stopThreadCompleted){
+ stopThreadCompleted=false;
+ }
+ // stop data channel
+ DataChannelThread.getInstance().stopNormal();
+ // stop message parser
+ MessageParser.getInstance().stopNormal();
+ // stop log parser
+ LogParser.getInstance().stopNormal();
+ // stop page data manager
+ DataManagerRegistry.stopThreadsNormal();
+ // stop other db inserters
+ CallStackInserter.getInstance().stopNormal();
+ synchronized(stopThreadCompleted){
+ stopThreadCompleted=true;
+ }
+ }
+ });
+
+ stopNormalThread.start();
+
+ setStageComplete(STAGE.STOP_DATATHREADS);
+
Project project = Global.getProject();
if (project != null && project.isValid()) {
project.setTotalStopTime(Toolbar.INSTANCE.getTime());
} else {
Logger.error("project is not valid to save");
}
- setStageComplete(STAGE.STOP_CALLSTACK_INSERTER);
+
}
// change summary UI
// if (!result.isSuccess()) {
// showError(result);
// }
-
- // set shortcut and toolbar UI as DA state
- ShortCutManager.getInstance().setEnabled(true);
- Toolbar.INSTANCE.changeUIState(DAState.getCurrentState());
+
+ // Enable ToolBar wait DataThreads clear completed.
+ Thread enableToolBar = new Thread(new Runnable() {
+ public void run() {
+ boolean checkCompleted = false;
+
+ synchronized(stopThreadCompleted){
+ checkCompleted = stopThreadCompleted;
+ }
+
+ while(checkCompleted==false){
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ break;
+ }
+
+ synchronized(stopThreadCompleted){
+ checkCompleted = stopThreadCompleted;
+ }
+ }
+ // set shortcut and toolbar UI as DA state
+ ShortCutManager.getInstance().setEnabled(true);
+ Toolbar.INSTANCE.changeUIState(DAState.getCurrentState());
+ }
+ });
+ enableToolBar.start();
}
}