{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/640","labels_url":"https://api.github.com/repos/realm/realm-java/issues/640/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/640/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/640/events","html_url":"https://github.com/realm/realm-java/issues/640","id":50952517,"number":640,"title":"ConcurrentModificationException when using iterators methods","user":{"login":"sergeyfitis","id":3204638,"avatar_url":"https://avatars.githubusercontent.com/u/3204638?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeyfitis","html_url":"https://github.com/sergeyfitis","followers_url":"https://api.github.com/users/sergeyfitis/followers","following_url":"https://api.github.com/users/sergeyfitis/following{/other_user}","gists_url":"https://api.github.com/users/sergeyfitis/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeyfitis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeyfitis/subscriptions","organizations_url":"https://api.github.com/users/sergeyfitis/orgs","repos_url":"https://api.github.com/users/sergeyfitis/repos","events_url":"https://api.github.com/users/sergeyfitis/events{/privacy}","received_events_url":"https://api.github.com/users/sergeyfitis/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/realm/realm-java/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/realm/realm-java/labels/P1","name":"P1","color":"ededed"},{"url":"https://api.github.com/repos/realm/realm-java/labels/Waiting-Core","name":"Waiting-Core","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2014-12-04T09:55:27Z","updated_at":"2015-07-24T14:08:22Z","closed_at":null,"body":"Hi, I have such exception even I using iterators methods:\r\nRealm version 0.75.1, Android studio 1.0rc2\r\n```\r\nCaused by: java.util.ConcurrentModificationException: No outside changes to a Realm is allowed while iterating a RealmResults. Use iterators methods instead.\r\n            at io.realm.RealmResults.assertRealmIsStable(RealmResults.java:405)\r\n            at io.realm.RealmResults.access$200(RealmResults.java:44)\r\n            at io.realm.RealmResults$RealmResultsIterator.hasNext(RealmResults.java:422)\r\n            at com.coachesdirectory.coach.db.RealmHelper$5.doInBackground(RealmHelper.java:360)\r\n            at com.coachesdirectory.coach.db.RealmHelper$5.doInBackground(RealmHelper.java:347)\r\n            at android.os.AsyncTask$2.call(AsyncTask.java:288)\r\n            at java.util.concurrent.FutureTask.run(FutureTask.java:237)\r\n            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)\r\n            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)\r\n            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)\r\n            at java.lang.Thread.run(Thread.java:818)\r\n```\r\n\r\nHere is part of my code:\r\n```\r\n****AsyncTask*****\r\nList<SchoolResult> favoriteSchools = params[0];\r\nRealm realm = Realm.getInstance(context);\r\nrealm.beginTransaction();\r\n\r\n// Set all schools to remove\r\nRealmResults<RealmSchoolResult> markToRemove = realm.where(RealmSchoolResult.class)\r\n                        .equalTo(\"userAccountId\", userId)\r\n                        .findAll();\r\nIterator<RealmSchoolResult> schoolResultIterator = markToRemove.iterator();\r\nwhile (schoolResultIterator.hasNext()) { // Crash at this line\r\n  RealmSchoolResult realmSchoolResult = schoolResultIterator.next();\r\n  realmSchoolResult.setNeedRemove(true);\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/124534655","html_url":"https://github.com/realm/realm-java/issues/640#issuecomment-124534655","issue_url":"https://api.github.com/repos/realm/realm-java/issues/640","id":124534655,"user":{"login":"alekseichuk","id":11341853,"avatar_url":"https://avatars.githubusercontent.com/u/11341853?v=3","gravatar_id":"","url":"https://api.github.com/users/alekseichuk","html_url":"https://github.com/alekseichuk","followers_url":"https://api.github.com/users/alekseichuk/followers","following_url":"https://api.github.com/users/alekseichuk/following{/other_user}","gists_url":"https://api.github.com/users/alekseichuk/gists{/gist_id}","starred_url":"https://api.github.com/users/alekseichuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alekseichuk/subscriptions","organizations_url":"https://api.github.com/users/alekseichuk/orgs","repos_url":"https://api.github.com/users/alekseichuk/repos","events_url":"https://api.github.com/users/alekseichuk/events{/privacy}","received_events_url":"https://api.github.com/users/alekseichuk/received_events","type":"User","site_admin":false},"created_at":"2015-07-24T14:08:22Z","updated_at":"2015-07-24T14:08:22Z","body":"Just got this as well. Use compile 'io.realm:realm-android:0.81.1'"}}