Reputation: 15313
In my app we are doing applyBatch for around 2000 records in worker thread.
at the same time if i rotate the screen i am getting black screen.
"main@6280" prio=5 waiting java.lang.Thread.State: WAITING blocks main@6280 at java.lang.Object.wait(Object.java:-1) at java.lang.Thread.parkFor$(Thread.java:1220) - locked <0x18c5> (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.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:810) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:844) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1173) at java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:196) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:257) at net.sqlcipher.database.SQLiteDatabase.lock(SQLiteDatabase.java:490) at net.sqlcipher.database.SQLiteProgram.close(SQLiteProgram.java:294) at net.sqlcipher.database.SQLiteQuery.close(SQLiteQuery.java:136) at net.sqlcipher.database.SQLiteCursor.close(SQLiteCursor.java:510) at android.database.CursorWrapper.close(CursorWrapper.java:50) at android.database.CursorWrapper.close(CursorWrapper.java:50) at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:2512) at android.database.CursorWrapper.close(CursorWrapper.java:50)
I have tried withYieldAllowed but no luck. Any idea why main thread is waiting for cursor close and any solution for this porblem?
Upvotes: 1
Views: 597
Reputation: 7474
at java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:196)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:257) at
debug and check which thread holds lock and why u got deadlock
when u do a db operation:
No lock on ReentrantLock
ReentrantLock locked for write by main thread
to build an android app essentially you need to have a knowledge about concurrency, synchronization, locks:
https://docs.oracle.com/javase/tutorial/essential/concurrency/ https://docs.oracle.com/javase/tutorial/essential/concurrency/sync.html https://docs.oracle.com/javase/tutorial/essential/concurrency/liveness.html
start digging from there: net.sqlcipher.database.SQLiteDatabase.lock(SQLiteDatabase.java:490)
Do you have this issue both on dalvik and art?
Upvotes: 1