主线程被Object.wait自己阻塞了?
我的布局有一个SurfaceView。 有时当我的应用从背景切换到前景时,我会得到ANR。 我认为原因是主线程被锁定方法阻塞。
最重要的部分是:
JNI:CheckJNI关闭; 解决方法已关闭; 销= 1; globals = 383(加1弱)
DALVIK THREADS :(互斥锁:tll = 0 tsl = 0 tscl = 0 ghl = 0)
“main”prio = 5 tid = 1 WAIT | group =“main”sCount = 1 dsCount = 0 obj = 0x4160fe58 self = 0x41529b58 | sysTid = 19249 nice = 0 sched = 0/0 cgrp = apps handle = 1074282836 | state = S schedstat =(140142818375 80057200431 501675)utm = 11559 stm = 2455 core = 1 java.lang.Object.wait(Native Method) - 等待由tid = 1持有的<0x4160ff28>(一个java.lang.VMThread) (主要)在java.lang.Thread.parkFor(Thread.java:1205)at sun.misc.Unsafe.park(Unsafe.java:325)at java.util.concurrent.locks.LockSupport.park(LockSupport.java:在java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:846)上的java.util.concurrent.locks.AbstractQueuedSynchronizer(java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:813) .acquire(AbstractQueuedSynchronizer.java:1175)在java.util.concurrent.locks.ReentrantLock中$ NonfairSync.lock(ReentrantLock.java:180)在java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:256)在android.view.SurfaceView.updateWindow(SurfaceView.java:524)at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:239)at android.view.View.dispatchW indowVisibilityChanged(View.java:8004)
在android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)在android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)在android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)在android.view。 ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)在android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1239)在android.view.ViewRootImpl.doTraversal(ViewRootImpl的.java:在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:5713)在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:761)在android.view.Choreographer.doCallbacks(编导1002)。 Java的:574)在android.view.Choreographer.doFrame(Choreographer.java:544)在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:747)在android.os.Handler.handleCallback(Handler.java:733 )在android.os.Handler.dispatchMessage(Handler.java:95) android.app.ActivityThread.main(ActivityThread.java:5120)上的android.os.Looper.loop(Looper.java:136)在java.lang.reflect上的java.lang.reflect.Method.invokeNative(Native Method) .Method.invoke(Method.java:515)在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:818)在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634 )在dalvik.system.NativeStart.main(本地方法)
你看到线程(id = 1)正在等待线程持有的锁(tid = 1)! 那怎么可能? 我对此有错误的理解吗?
链接地址: http://www.djcxy.com/p/61981.html