I am executing a command with Runtime.getRuntime().exec(cmd)
inside my app. As it takes long to finish execution(several minutes), I have put it inside a thread. but with thread approach also app is getting suspended halfway and I see this message:
threadid=3: reacting to signal 3
Wrote stack traces to '/data/anr/traces.txt'
following is the code that I am using:
Thread thread = new Thread() {
public void run() {
Process process = Runtime.getRuntime().exec(cmd);
//cmd : command to be executed
process.waitFor();
}
};
thread.start();
thread.join();
What am I missing here? How can I prevent my app from getting suspended due to long processing time?
Note: I know that there are other approaches such as AsyncTask etc. but I don't think it will make any different in this case. (or will it?)