ANR执行异步任务

时间:2017-07-28 09:18:41

标签: android android-asynctask android-anr-dialog

我在应用程序中有一个ANR问题。我有两个我正在测试的设备(htcm8和一个三星tab3),我无法重现这个问题。

我的应用程序有几个片段(~10),大多数都做asynctask所以我怀疑某处有锁,但我不确定。我通过一次真正启动多个线程(asynctask)进行测试,并让它们尽可能长时间运行,我从来没有得到ANR。

我的主要问题是ANR的堆栈跟踪非常难以阅读和理解(崩溃更容易:))。是否有一些指导从哪里开始。

我查看了stackoverflow,这是一些很好的东西,但我没有关于我们应该寻找的东西的详细白皮书?由于我不进行调试(ANR发生在远程站点),有什么要看的东西?

https://developer.android.com/training/articles/perf-anr.html没用?

以下是GetInfoWan.java的第166行:

        ipwan = new GetIP_WAN().execute("127.0.0.1").get();

以下是我的追踪示例。看起来有很多asyctasks同时运行,但我找不到“等待锁定”。

Jul 26, 2:12 PM on app version 17
HTC ONE M8s (htc_m8qlul), 2048MB RAM, Android 6.0
Report 1 of 17


EXPAND ALL
"main" tid=1 Waiting 
"main" prio=5 tid=1 Waiting
  | group="main" sCount=1 dsCount=0 obj=0x759befa8 self=0x55a086a060
  | sysTid=21078 nice=-4 cgrp=default sched=0/0 handle=0x7fa9628fe8
  | state=S schedstat=( 0 0 0 ) utm=638 stm=79 core=3 HZ=100
  | stack=0x7fc6afc000-0x7fc6afe000 stackSize=8MB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x0010824c> (a java.lang.Object)
  at java.lang.Thread.parkFor$ (Thread.java:1220)
- locked <0x0010824c> (a java.lang.Object)
  at sun.misc.Unsafe.park (Unsafe.java:299)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:158)
  at java.util.concurrent.FutureTask.awaitDone (FutureTask.java:421)
  at java.util.concurrent.FutureTask.get (FutureTask.java:163)
  at android.os.AsyncTask.get (AsyncTask.java:498)
  at com.bernard_zelmans.checksecurityPremium.Connectivity.GetInfoWan.getWanIpAddress (GetInfoWan.java:166)
  at com.bernard_zelmans.checksecurityPremium.Discovery.DiscoverFragment.onActivityCreated (DiscoverFragment.java:187)
  at android.app.Fragment.performActivityCreated (Fragment.java:2246)
  at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:996)
  at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1152)
  at android.app.BackStackRecord.run (BackStackRecord.java:793)
  at android.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1539)
  at android.app.FragmentManagerImpl$1.run (FragmentManager.java:482)
  at android.os.Handler.handleCallback (Handler.java:739)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:168)
  at android.app.ActivityThread.main (ActivityThread.java:5885)
  at java.lang.reflect.Method.invoke! (Native method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:797)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:687)
"FinalizerWatchdogDaemon" tid=4 Waiting 
"FinalizerWatchdogDaemon" daemon prio=5 tid=4 Waiting
  | group="system" sCount=1 dsCount=0 obj=0x12d3ebe0 self=0x55a0dc6f60
  | sysTid=21087 nice=0 cgrp=default sched=0/0 handle=0x7fa51d4450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
  | stack=0x7fa50d2000-0x7fa50d4000 stackSize=1037KB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x0182d295> (a java.lang.Daemons$FinalizerWatchdogDaemon)
  at java.lang.Daemons$FinalizerWatchdogDaemon.waitForObject (Daemons.java:270)
- locked <0x0182d295> (a java.lang.Daemons$FinalizerWatchdogDaemon)
  at java.lang.Daemons$FinalizerWatchdogDaemon.run (Daemons.java:235)
  at java.lang.Thread.run (Thread.java:818)
"FinalizerDaemon" tid=5 Waiting 
"FinalizerDaemon" daemon prio=5 tid=5 Waiting
  | group="system" sCount=1 dsCount=0 obj=0x12d3eb80 self=0x55a0dc6700
  | sysTid=21086 nice=0 cgrp=default sched=0/0 handle=0x7fa52db450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=1 core=2 HZ=100
  | stack=0x7fa51d9000-0x7fa51db000 stackSize=1037KB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x051b3faa> (a java.lang.ref.ReferenceQueue)
  at java.lang.Object.wait (Object.java:423)
  at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:101)
- locked <0x051b3faa> (a java.lang.ref.ReferenceQueue)
  at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:72)
  at java.lang.Daemons$FinalizerDaemon.run (Daemons.java:193)
  at java.lang.Thread.run (Thread.java:818)
"ReferenceQueueDaemon" tid=7 Waiting 
"ReferenceQueueDaemon" daemon prio=5 tid=7 Waiting
  | group="system" sCount=1 dsCount=0 obj=0x12d3eb20 self=0x55a0dc5ea0
  | sysTid=21085 nice=0 cgrp=default sched=0/0 handle=0x7fa53e2450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
  | stack=0x7fa52e0000-0x7fa52e2000 stackSize=1037KB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x017c179b> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
  at java.lang.Daemons$ReferenceQueueDaemon.run (Daemons.java:155)
- locked <0x017c179b> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
  at java.lang.Thread.run (Thread.java:818)
"Binder_1" tid=8 Native 
"Binder_1" prio=5 tid=8 Native
  | group="main" sCount=1 dsCount=0 obj=0x12d590a0 self=0x55a0dc8020
  | sysTid=21089 nice=0 cgrp=default sched=0/0 handle=0x7fa4db6450
  | state=S schedstat=( 0 0 0 ) utm=2 stm=0 core=0 HZ=100
  | stack=0x7fa4cba000-0x7fa4cbc000 stackSize=1013KB
  | held mutexes=
  native: pc 000000000006ac40  /system/lib64/libc.so (__ioctl+4)
  native: pc 0000000000074c64  /system/lib64/libc.so (ioctl+100)
  native: pc 000000000002d8fc  /system/lib64/libbinder.so (_ZN7android14IPCThreadState14talkWithDriverEb+164)
  native: pc 000000000002e1fc  /system/lib64/libbinder.so (_ZN7android14IPCThreadState20getAndExecuteCommandEv+24)
  native: pc 000000000002e328  /system/lib64/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+92)
  native: pc 0000000000037648  /system/lib64/libbinder.so (???)
  native: pc 0000000000017b6c  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+208)
  native: pc 0000000000090910  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+140)
  native: pc 0000000000017308  /system/lib64/libutils.so (???)
  native: pc 00000000000686c4  /system/lib64/libc.so (_ZL15__pthread_startPv+52)
  native: pc 000000000001c7c4  /system/lib64/libc.so (__start_thread+16)
"Binder_2" tid=9 Native 
"Binder_2" prio=5 tid=9 Native
  | group="main" sCount=1 dsCount=0 obj=0x12d650a0 self=0x55a0dc8880
  | sysTid=21090 nice=0 cgrp=default sched=0/0 handle=0x7fa4cb0450
  | state=S schedstat=( 0 0 0 ) utm=2 stm=0 core=2 HZ=100
  | stack=0x7fa4bb4000-0x7fa4bb6000 stackSize=1013KB
  | held mutexes=
  native: pc 000000000006ac40  /system/lib64/libc.so (__ioctl+4)
  native: pc 0000000000074c64  /system/lib64/libc.so (ioctl+100)
  native: pc 000000000002d8fc  /system/lib64/libbinder.so (_ZN7android14IPCThreadState14talkWithDriverEb+164)
  native: pc 000000000002e1fc  /system/lib64/libbinder.so (_ZN7android14IPCThreadState20getAndExecuteCommandEv+24)
  native: pc 000000000002e328  /system/lib64/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+92)
  native: pc 0000000000037648  /system/lib64/libbinder.so (???)
  native: pc 0000000000017b6c  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+208)
  native: pc 0000000000090910  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+140)
  native: pc 0000000000017308  /system/lib64/libutils.so (???)
  native: pc 00000000000686c4  /system/lib64/libc.so (_ZL15__pthread_startPv+52)
  native: pc 000000000001c7c4  /system/lib64/libc.so (__start_thread+16)
"Thread-81073" tid=10 Native 
"Thread-81073" prio=5 tid=10 Native
  | group="main" sCount=1 dsCount=0 obj=0x12d6bb80 self=0x55a0dd4a60
  | sysTid=21207 nice=0 cgrp=default sched=0/0 handle=0x7f9ff7f450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1 HZ=100
  | stack=0x7f9fe7d000-0x7f9fe7f000 stackSize=1037KB
  | held mutexes=
  native: pc 000000000006aaf0  /system/lib64/libc.so (__accept4+4)
  native: pc 0000000000001044  /system/lib64/libnetd_client.so (???)
  native: pc 000000000001bc7c  /system/lib64/libc.so (accept4+16)
  native: pc 00000000000d8d10  /system/lib64/libandroid_runtime.so (???)
  native: pc 0000000000350c54  /system/framework/arm64/boot.oat (Java_android_net_LocalSocketImpl_accept__Ljava_io_FileDescriptor_2Landroid_net_LocalSocketImpl_2+184)
  at android.net.LocalSocketImpl.accept (Native method)
  at android.net.LocalSocketImpl.accept (LocalSocketImpl.java:331)
  at android.net.LocalServerSocket.accept (LocalServerSocket.java:90)
  at com.android.tools.fd.runtime.Server$SocketServerThread.run (Server.java:157)
  at java.lang.Thread.run (Thread.java:818)
"RenderThread" tid=11 Native 
"RenderThread" prio=5 tid=11 Native
  | group="main" sCount=1 dsCount=0 obj=0x13ab00a0 self=0x55a0b12c90
  | sysTid=21300 nice=-4 cgrp=default sched=0/0 handle=0x7f9fe15450
  | state=S schedstat=( 0 0 0 ) utm=762 stm=242 core=0 HZ=100
  | stack=0x7f9fd19000-0x7f9fd1b000 stackSize=1013KB
  | held mutexes=
  native: pc 000000000006ab54  /system/lib64/libc.so (__epoll_pwait+8)
  native: pc 000000000001ce24  /system/lib64/libc.so (epoll_pwait+32)
  native: pc 000000000001d560  /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+144)
  native: pc 000000000001d9c8  /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+80)
  native: pc 000000000002bc90  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread12RenderThread10threadLoopEv+100)
  native: pc 0000000000017b6c  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+208)
  native: pc 0000000000090910  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+140)
  native: pc 0000000000017308  /system/lib64/libutils.so (???)
  native: pc 00000000000686c4  /system/lib64/libc.so (_ZL15__pthread_startPv+52)
  native: pc 000000000001c7c4  /system/lib64/libc.so (__start_thread+16)
"IntentService[ServiceSocket]" tid=12 Native 
"IntentService[ServiceSocket]" prio=5 tid=12 Native
  | group="main" sCount=1 dsCount=0 obj=0x13870f40 self=0x55a1066580
  | sysTid=21301 nice=0 cgrp=default sched=0/0 handle=0x7f8e650450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=7 HZ=100
  | stack=0x7f8e54e000-0x7f8e550000 stackSize=1037KB
  | held mutexes=
  native: pc 000000000006ab54  /system/lib64/libc.so (__epoll_pwait+8)
  native: pc 000000000001ce24  /system/lib64/libc.so (epoll_pwait+32)
  native: pc 000000000001d560  /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+144)
  native: pc 000000000001d9c8  /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+80)
  native: pc 00000000000d5180  /system/lib64/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+48)
  native: pc 000000000000087c  /system/framework/arm64/boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+144)
  at android.os.MessageQueue.nativePollOnce (Native method)
  at android.os.MessageQueue.next (MessageQueue.java:323)
  at android.os.Looper.loop (Looper.java:144)
  at android.os.HandlerThread.run (HandlerThread.java:61)
"Thread-81076" tid=13 Native 
"Thread-81076" prio=5 tid=13 Native
  | group="main" sCount=1 dsCount=0 obj=0x1386da50 self=0x55a10675e0
  | sysTid=21302 nice=0 cgrp=default sched=0/0 handle=0x7f8e54b450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=4 HZ=100
  | stack=0x7f8e449000-0x7f8e44b000 stackSize=1037KB
  | held mutexes=
  native: pc 000000000006aaf0  /system/lib64/libc.so (__accept4+4)
  native: pc 0000000000001044  /system/lib64/libnetd_client.so (???)
  native: pc 000000000001bc7c  /system/lib64/libc.so (accept4+16)
  native: pc 0000000000039614  /system/lib64/libjavacore.so (???)
  native: pc 0000000000350c54  /system/framework/arm64/boot.oat (Java_libcore_io_Posix_accept__Ljava_io_FileDescriptor_2Ljava_net_InetSocketAddress_2+184)
  at libcore.io.Posix.accept (Native method)
  at libcore.io.BlockGuardOs.accept (BlockGuardOs.java:63)
  at java.net.PlainSocketImpl.accept (PlainSocketImpl.java:89)
  at java.net.ServerSocket.implAccept (ServerSocket.java:217)
- locked <0x0c0b0311> (a java.net.ServerSocket)
  at java.net.ServerSocket.accept (ServerSocket.java:141)
  at com.bernard_zelmans.checksecurityPremium.ServiceSocket$ServerThread.run (ServiceSocket.java:58)
"PowerManagerThread" tid=14 Native 
"PowerManagerThread" prio=5 tid=14 Native
  | group="main" sCount=1 dsCount=0 obj=0x13abb7c0 self=0x55a0a4c880
  | sysTid=21305 nice=0 cgrp=default sched=0/0 handle=0x7f8e446450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1 HZ=100
  | stack=0x7f8e344000-0x7f8e346000 stackSize=1037KB
  | held mutexes=
  native: pc 000000000006ab54  /system/lib64/libc.so (__epoll_pwait+8)
  native: pc 000000000001ce24  /system/lib64/libc.so (epoll_pwait+32)
  native: pc 000000000001d560  /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+144)
  native: pc 000000000001d9c8  /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+80)
  native: pc 00000000000d5180  /system/lib64/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+48)
  native: pc 000000000000087c  /system/framework/arm64/boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+144)
  at android.os.MessageQueue.nativePollOnce (Native method)
  at android.os.MessageQueue.next (MessageQueue.java:323)
  at android.os.Looper.loop (Looper.java:144)
  at android.os.HandlerThread.run (HandlerThread.java:61)
"hwuiTask1" tid=15 Native 
"hwuiTask1" prio=5 tid=15 Native
  | group="main" sCount=1 dsCount=0 obj=0x13ae40a0 self=0x55a1237220
  | sysTid=21321 nice=-2 cgrp=default sched=0/0 handle=0x7f8da7c450
  | state=S schedstat=( 0 0 0 ) utm=56 stm=13 core=0 HZ=100
  | stack=0x7f8d980000-0x7f8d982000 stackSize=1013KB
  | held mutexes=
  native: pc 0000000000019b40  /system/lib64/libc.so (syscall+28)
  native: pc 00000000000683e4  /system/lib64/libc.so (_ZL33__pthread_cond_timedwait_relativeP23pthread_cond_internal_tP15pthread_mutex_tPK8timespec+96)
  native: pc 000000000002ca68  /system/lib64/libhwui.so (???)
  native: pc 0000000000017b6c  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+208)
  native: pc 0000000000090910  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+140)
  native: pc 0000000000017308  /system/lib64/libutils.so (???)
  native: pc 00000000000686c4  /system/lib64/libc.so (_ZL15__pthread_startPv+52)
  native: pc 000000000001c7c4  /system/lib64/libc.so (__start_thread+16)
"hwuiTask2" tid=16 Native 
"hwuiTask2" prio=5 tid=16 Native
  | group="main" sCount=1 dsCount=0 obj=0x13ae80a0 self=0x55a121fcd0
  | sysTid=21322 nice=-2 cgrp=default sched=0/0 handle=0x7f8d976450
  | state=S schedstat=( 0 0 0 ) utm=17 stm=5 core=3 HZ=100
  | stack=0x7f8d87a000-0x7f8d87c000 stackSize=1013KB
  | held mutexes=
  native: pc 0000000000019b40  /system/lib64/libc.so (syscall+28)
  native: pc 00000000000683e4  /system/lib64/libc.so (_ZL33__pthread_cond_timedwait_relativeP23pthread_cond_internal_tP15pthread_mutex_tPK8timespec+96)
  native: pc 000000000002ca68  /system/lib64/libhwui.so (???)
  native: pc 0000000000017b6c  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+208)
  native: pc 0000000000090910  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+140)
  native: pc 0000000000017308  /system/lib64/libutils.so (???)
  native: pc 00000000000686c4  /system/lib64/libc.so (_ZL15__pthread_startPv+52)
  native: pc 000000000001c7c4  /system/lib64/libc.so (__start_thread+16)
"AsyncTask #1" tid=17 Waiting 
"AsyncTask #1" prio=5 tid=17 Waiting
  | group="main" sCount=1 dsCount=0 obj=0x13b39a60 self=0x55a1381570
  | sysTid=21495 nice=0 cgrp=default sched=0/0 handle=0x7f8be0b450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=2 HZ=100
  | stack=0x7f8bd09000-0x7f8bd0b000 stackSize=1037KB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x06fa9277> (a java.lang.Object)
  at java.lang.Thread.parkFor$ (Thread.java:1220)
- locked <0x06fa9277> (a java.lang.Object)
  at sun.misc.Unsafe.park (Unsafe.java:299)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:158)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2013)
  at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:410)
  at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1036)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1098)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
  at java.lang.Thread.run (Thread.java:818)
"AsyncTask #2" tid=18 Waiting 
"AsyncTask #2" prio=5 tid=18 Waiting
  | group="main" sCount=1 dsCount=0 obj=0x13b39ac0 self=0x55a142c460
  | sysTid=21497 nice=0 cgrp=default sched=0/0 handle=0x7f8bd06450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=3 HZ=100
  | stack=0x7f8bc04000-0x7f8bc06000 stackSize=1037KB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x005acee4> (a java.lang.Object)
  at java.lang.Thread.parkFor$ (Thread.java:1220)
- locked <0x005acee4> (a java.lang.Object)
  at sun.misc.Unsafe.park (Unsafe.java:299)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:158)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2013)
  at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:410)
  at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1036)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1098)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
  at java.lang.Thread.run (Thread.java:818)
"AsyncTask #3" tid=19 Native 
"AsyncTask #3" prio=5 tid=19 Native
  | group="main" sCount=1 dsCount=0 obj=0x13b7c6a0 self=0x55a1533a00
  | sysTid=21630 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0x7f8b17f450
  | state=S schedstat=( 0 0 0 ) utm=10 stm=4 core=0 HZ=100
  | stack=0x7f8b07d000-0x7f8b07f000 stackSize=1037KB
  | held mutexes=
  native: pc 000000000006b618  /system/lib64/libc.so (read+4)
  native: pc 000000000003798c  /system/lib64/libjavacore.so (???)
  native: pc 0000000000610b44  /system/framework/arm64/boot.oat (Java_libcore_io_Posix_readBytes__Ljava_io_FileDescriptor_2Ljava_lang_Object_2II+200)
  at libcore.io.Posix.readBytes (Native method)
  at libcore.io.Posix.read (Posix.java:169)
  at libcore.io.BlockGuardOs.read (BlockGuardOs.java:230)
  at libcore.io.IoBridge.read (IoBridge.java:468)
  at java.io.FileInputStream.read (FileInputStream.java:177)
  at java.io.InputStreamReader.read (InputStreamReader.java:233)
- locked <0x0a0bbf4d> (a java.lang.ProcessManager$ProcessInputStream)
  at java.io.BufferedReader.fillBuf (BufferedReader.java:145)
  at java.io.BufferedReader.readLine (BufferedReader.java:397)
- locked <0x0dd81a02> (a java.io.InputStreamReader)
  at com.bernard_zelmans.checksecurityPremium.PingTest.PingTestFragment$Ping.doInBackground (PingTestFragment.java:393)
  at com.bernard_zelmans.checksecurityPremium.PingTest.PingTestFragment$Ping.doInBackground (PingTestFragment.java:365)
  at android.os.AsyncTask$2.call (AsyncTask.java:295)
  at java.util.concurrent.FutureTask.run (FutureTask.java:237)
  at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:234)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1113)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
  at java.lang.Thread.run (Thread.java:818)
"AsyncTask #8" tid=20 Waiting 
"AsyncTask #8" prio=5 tid=20 Waiting
  | group="main" sCount=1 dsCount=0 obj=0x13c5f820 self=0x55a15b1950
  | sysTid=21803 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0x7f8b075450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=1 core=1 HZ=100
  | stack=0x7f8af73000-0x7f8af75000 stackSize=1037KB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x02bb596f> (a java.lang.Object)
  at java.lang.Thread.parkFor$ (Thread.java:1220)
- locked <0x02bb596f> (a java.lang.Object)
  at sun.misc.Unsafe.park (Unsafe.java:299)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:158)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2013)
  at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:410)
  at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1036)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1098)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
  at java.lang.Thread.run (Thread.java:818)
"AsyncTask #4" tid=21 Waiting 
"AsyncTask #4" prio=5 tid=21 Waiting
  | group="main" sCount=1 dsCount=0 obj=0x13b7c760 self=0x55a1463bb0
  | sysTid=21632 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0x7f8af6b450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=1 core=3 HZ=100
  | stack=0x7f8ae69000-0x7f8ae6b000 stackSize=1037KB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x0c7bdf13> (a java.lang.Object)
  at java.lang.Thread.parkFor$ (Thread.java:1220)
- locked <0x0c7bdf13> (a java.lang.Object)
  at sun.misc.Unsafe.park (Unsafe.java:299)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:158)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2013)
  at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:410)
  at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1036)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1098)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
  at java.lang.Thread.run (Thread.java:818)
"WifiManager" tid=22 Native 
"WifiManager" prio=5 tid=22 Native
  | group="main" sCount=1 dsCount=0 obj=0x13b7c7c0 self=0x55a1422dc0
  | sysTid=21639 nice=0 cgrp=default sched=0/0 handle=0x7f8ae61450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=3 HZ=100
  | stack=0x7f8ad5f000-0x7f8ad61000 stackSize=1037KB
  | held mutexes=
  native: pc 000000000006ab54  /system/lib64/libc.so (__epoll_pwait+8)
  native: pc 000000000001ce24  /system/lib64/libc.so (epoll_pwait+32)
  native: pc 000000000001d560  /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+144)
  native: pc 000000000001d9c8  /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+80)
  native: pc 00000000000d5180  /system/lib64/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+48)
  native: pc 000000000000087c  /system/framework/arm64/boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+144)
  at android.os.MessageQueue.nativePollOnce (Native method)
  at android.os.MessageQueue.next (MessageQueue.java:323)
  at android.os.Looper.loop (Looper.java:144)
  at android.os.HandlerThread.run (HandlerThread.java:61)
"AsyncTask #5" tid=23 Waiting 
"AsyncTask #5" prio=5 tid=23 Waiting
  | group="main" sCount=1 dsCount=0 obj=0x13b7c8e0 self=0x55a142d880
  | sysTid=21640 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0x7f8ad55450
  | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=2 HZ=100
  | stack=0x7f8ac53000-0x7f8ac55000 stackSize=1037KB
  | held mutexes=
  at java.lang.Object.wait! (Native method)
- waiting on <0x0a67f550> (a java.lang.Object)
  at java.lang.Thread.parkFor$ (Thread.java:1220)
- locked <0x0a67f550> (a java.lang.Object)
  at sun.misc.Unsafe.park (Unsafe.java:299)
  at java.util.concurrent.locks.LockSupport.park  

1 个答案:

答案 0 :(得分:0)

问题是get()方法,它将在AsyncTask完成之前阻塞。 AsyncTasks具有有限的线程池大小,因此如果还有许多其他AsyncTasks,则在GetIP_WAN AsyncTask完成之前,您必须等待其他任务完成。

你应该做的不是使用get(),而是覆盖AsyncTask中的onPostExecute方法来获得结果。