0
當同一進程中有兩個不同的線程試圖同時持續存在時,我們正在測試greendao中的併發問題。與greendao並行插入dao;執行BEGIN EXCLUSIVE時數據庫被鎖定
我們在同一個進程中產生兩個線程,並讓他們同時插入100個隨機填充的dao。
GreenDao版本1.3.0
請讓我知道如果我們做錯了什麼,或者如果你需要更多的信息,謝謝!
我們不斷收到此錯誤:
04-04 14:29:48.528: E/Database(17736): Failure 5 (database is locked) on 0x2d4c98 when executing 'BEGIN EXCLUSIVE;'
04-04 14:29:48.528: W/dalvikvm(17736): threadid=10: thread exiting with uncaught exception (group=0x40018560)
04-04 14:29:48.538: E/AndroidRuntime(17736): FATAL EXCEPTION: Thread-11
04-04 14:29:48.538: E/AndroidRuntime(17736): android.database.sqlite.SQLiteException: database is locked: BEGIN EXCLUSIVE;
04-04 14:29:48.538: E/AndroidRuntime(17736): at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)
04-04 14:29:48.538: E/AndroidRuntime(17736): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1772)
04-04 14:29:48.538: E/AndroidRuntime(17736): at android.database.sqlite.SQLiteDatabase.beginTransactionWithListener(SQLiteDatabase.java:536)
04-04 14:29:48.538: E/AndroidRuntime(17736): at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:490)
04-04 14:29:48.538: E/AndroidRuntime(17736): at de.greenrobot.dao.AbstractDao.executeInsert(AbstractDao.java:344)
04-04 14:29:48.538: E/AndroidRuntime(17736): at de.greenrobot.dao.AbstractDao.insert(AbstractDao.java:293)
這裏是我的代碼,用於插入一個DAO:
getGreenDaoSession().getMyDao().insert(this.myDao);