{"action":"opened","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/1474","labels_url":"https://api.github.com/repos/realm/realm-java/issues/1474/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/1474/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/1474/events","html_url":"https://github.com/realm/realm-java/issues/1474","id":106815814,"number":1474,"title":"Closing realm instance in the origin thread if it was interrupted","user":{"login":"kboyarshinov","id":1917615,"avatar_url":"https://avatars.githubusercontent.com/u/1917615?v=3","gravatar_id":"","url":"https://api.github.com/users/kboyarshinov","html_url":"https://github.com/kboyarshinov","followers_url":"https://api.github.com/users/kboyarshinov/followers","following_url":"https://api.github.com/users/kboyarshinov/following{/other_user}","gists_url":"https://api.github.com/users/kboyarshinov/gists{/gist_id}","starred_url":"https://api.github.com/users/kboyarshinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kboyarshinov/subscriptions","organizations_url":"https://api.github.com/users/kboyarshinov/orgs","repos_url":"https://api.github.com/users/kboyarshinov/repos","events_url":"https://api.github.com/users/kboyarshinov/events{/privacy}","received_events_url":"https://api.github.com/users/kboyarshinov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-16T16:57:22Z","updated_at":"2015-09-16T16:57:22Z","closed_at":null,"body":"I have an [issue](https://github.com/kboyarshinov/realm-rxjava-example/issues/1) in my *realm-rxjava-example* project with updated Realm to 0.82 when realm instances should be closed in the same thread they were created.\r\n\r\nAssuming that Realm is doing some blocking IO work internally and the running thread can be interrupted, this situation needs to be properly handled with closing Realm instance. \r\n\r\nI see that Realm methods like `copyToRealm` or any generated setters do not throw `InterruptedException`. Does it mean that Realm catches interrupted exception internally and swallows it? Or does it call `Thread.currentThread().interrupt()` in case of caught interruption? I'm asking this cause I could not find these lines in source code.\r\n\r\nIf interruption is swallowed then the following code will wait while realm work is done and then exits the loop:\r\n```java\r\nThread thread = new Thread() {\r\n  @Override\r\n  public void run() {\r\n    Realm realm = Realm.getDefaultIntstance();\r\n    while (!Thread.currentThread().isInterrupted()) {\r\n      // do some work in realm\r\n    }\r\n    realm.close();\r\n  }\r\n};\r\n\r\nthread.start();\r\nthread.interrupt();\r\n```\r\nThe code is basically existing [threading example](https://github.com/realm/realm-java/blob/master/examples/threadExample/src/main/java/io/realm/examples/threads/ThreadFragment.java). And it works like I described in my tests.\r\n\r\nDoes it mean that Realm IO process can not be interrupted?\r\n\r\nPlease correct me if my assumptions are wrong. I solved my issue with handling thread interruption manually but I need to be sure that realm is working as I think it works.\r\nThanks in advance."}}