0
我不斷收到:域訪問時,它是在同一個線程
java.lang.IllegalStateException: Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created.
但是線程已經被它甚至倒是一種境界對象,我解決這個任何時候中斷?
RealmConfiguration config = new RealmConfiguration.Builder()
.name("CustomSchedule.realm")
.schemaVersion(42)
.build();
mRealm = Realm.getInstance(config);
mDays = app.getmDays();
final Handler handler = new Handler();
t = new Thread(new Runnable() {
public void run() {
while(!Thread.currentThread().isInterrupted()) {
while (mDays.isEmpty()) {
}
Thread.currentThread().interrupt();
startActivity();
handler.post(this);
}
}
});
t.start();
return rootView;
}
在startActivity部分中,我像往常一樣引用領域對象。