当同一进程中有两个不同的线程试图同时保持时,我们正在测试 greendao 的并发问题。
我们在同一个进程中生成两个线程,并让它们同时插入 100 个随机填充的 dao。
绿道 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);