java.util.concurrent.RejectedExecutionException:池=128/128,队列=10/10 [英] java.util.concurrent.RejectedExecutionException: pool=128/128, queue=10/10
问题描述
我在 logcat 中采用以下内容:
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)
我在一个活动中使用 asynctask(如果这很重要,从我上面看到的)但是即使我不执行 asynctask 我也会收到错误.
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();
}
}
logcat 不断给予:
The logcat keeps giving:
GC_CONCURRENT 释放 465K,46% 释放 3184K/5895K,外部 1061K/1573K,暂停 4ms+5ms
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.
为了拥有:
处理系统重启以确保通知可以继续系统重新启动后收到以下附加代码和需要配置.
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
}
}
对于广告控制器:
//Leadbolt code
myController = new AdController(this, "111111");
myController.loadStartAd("22222222", "222222");
public void onDestroy()
{
myController.destroyAd();
super.onDestroy();
}
推荐答案
来自 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
如果您查看 AsyncTask 源代码,这里,你会发现
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:
您创建了太多的 AsyncTask.超出允许范围.
这篇关于java.util.concurrent.RejectedExecutionException:池=128/128,队列=10/10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!