I got these kind of exception similar to AsyncTask, RejectedExecutionException and Task Limit, and "grab code and add to my package".My question is: is this the right anwser, anyone have other official solutions?
java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@416cd2e0 rejected from java.util.concurrent.ThreadPoolExecutor@4101be78[Running, pool size = 128, active threads = 128, queued tasks = 10, completed tasks = 53]
updateTimer.schedule(updateTask, 500, 3000);
...
updateTask = new TimerTask() {
public void run()
{
updateHandler.sendMessage(msg);
}
};
...
updateHandler = new Handler() {
public void handleMessage(Message msg)
{
updateAsync();
}
};
...
new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... params)
{
retrieveStatus();
return null;
}
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
updateStatusUi();// !!!?
}
}.execute();
updateTask = new TimerTask() {
public void run()
{
retrieveStatus();
getActivity().runOnUiThread(new Runnable() {
public void run()
{
updateStatusUi();
}
});
}
};
IN ICS: After about 10 times, it never update any more. Can you please give me a Demo, so I can pass some rigor test like: MainActivity: open(), close(), ...
P.S. myAsyncTask.executeOnExecutor(MyAsyncTask.SERIAL_EXECUTOR, [params] ); will work?