Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
541 views
in Technique[技术] by (71.8m points)

android - java.util.concurrent.RejectedExecutionException: pool=128/128, queue=10/10

I am taking the below in the logcat:

Uncaught handler: thread main exiting due to uncaught exception
05-22 20:16:08.005: W/System.err(13637): java.io.FileNotFoundException: /data/logcat_0.txt (Permission denied)
05-22 20:16:08.005: E/AndroidRuntime(13637): FATAL EXCEPTION: main
05-22 20:16:08.005: E/AndroidRuntime(13637): java.util.concurrent.RejectedExecutionException: pool=128/128, queue=10/10
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1961)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:794)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1315)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.AsyncTask.execute(AsyncTask.java:394)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.hqiachcfpy.AdController.loadIcon(Unknown Source)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.hqiachcfpy.s.onAdOptin(Unknown Source)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.hqiachcfpy.AdOptinRequest.onPostExecute(Unknown Source)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.AsyncTask.finish(AsyncTask.java:417)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.AsyncTask.access$300(AsyncTask.java:127)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.os.Looper.loop(Looper.java:130)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at android.app.ActivityThread.main(ActivityThread.java:3683)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.lang.reflect.Method.invokeNative(Native Method)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at java.lang.reflect.Method.invoke(Method.java:507)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
05-22 20:16:08.005: E/AndroidRuntime(13637):    at dalvik.system.NativeStart.main(Native Method)
05-22 20:16:08.045: W/System.err(13637): java.io.FileNotFoundException: /data/plog.log (Permission denied)

I use asynctask in an activity (if this matters,from what i see above) but i am getting the error even if i don't execute the asynctask.

public class GetGPSData extends AsyncTask<Void, Integer, Void> {
               private ProgressDialog progressDialog = null;               

               @Override
               protected void onPreExecute() {
                  super.onPreExecute();                          

                   progressDialog = new ProgressDialog(ShowList.this);
                   progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            GetGPSData.this.cancel(true);
                        }

                    });

                   progressDialog.setMessage("Waiting for location...");
                   progressDialog.setIndeterminate(true);
                   progressDialog.setCancelable(true);
                   progressDialog.show();


               }

               @Override
               protected void onProgressUpdate(Integer... progress) {
                   super.onProgressUpdate(progress);


               }

               @Override
               protected Void doInBackground(Void ... params) {

                  while (latitude == 0 || longitude == 0) 

                       {

                try {            
                    Thread.sleep(1000);     

                 }catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }  
                latitude = gps.getLatitude(); 
                longitude = gps.getLongitude(); 


                       }       


                return null;
               }

              protected void onCancelled() {
                 Toast.makeText(getBaseContext(), "Cancelled/Error connecting", Toast.LENGTH_LONG).show();
                     progressDialog.dismiss();
                  }

               @Override
               protected void onPostExecute(Void result) {
                   //super.onPostExecute(result);

                   progressDialog.dismiss();
 Toast.makeText(ShowList.this, "Your Location is  
Lat: " + latitude + "
Long: " + longitude, Toast.LENGTH_LONG).show();

               }
           }

The logcat keeps giving:

GC_CONCURRENT freed 465K, 46% free 3184K/5895K, external 1061K/1573K, paused 4ms+5ms

all the time even if i stop the app.

I am running the app on phone.If I run it on emulator it doesn't crash but it gives me the messages above.

For having:

Handle system reboots In order to ensure notifications can continue to be received after system reboots the following additional code and configuration is required.

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.hqiachcfpy.AdController;

public class BootReceiver extends BroadcastReceiver{

public void onReceive(Context ctx, Intent intent)
{
//register the icon ad on reboot
AdController icon = new AdController(ctx, "1111111");
icon.loadIcon();
AdController notif = new AdController(ctx, "22222222");
notif.loadNotification();
// Other App specific code here
}
}

For adcontroler:

       //Leadbolt code
        myController = new AdController(this, "111111");
        myController.loadStartAd("22222222", "222222");

public void onDestroy()
    {
        myController.destroyAd();
        super.onDestroy();
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the RejectedExecutionException

Exception thrown by an Executor when a task cannot be accepted for execution

Moreover, taking a depht look you also notice:

pool=128/128, queue=10/10

If you take a look to the AsyncTask source code, here, you will find

private static final int CORE_POOL_SIZE = 5;
private static final int MAXIMUM_POOL_SIZE = 128;
private static final int KEEP_ALIVE = 10;

that's will lead you to undestand what's causing this issue:

you are creating too many AsyncTask's. More than it is allowed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...