Source:
public void interruptWaits() throws InterruptedException { final SyncUser user = UserFactory.createUniqueUser(Constants.AUTH_URL); SyncUser adminUser = UserFactory.createAdminUser(Constants.AUTH_URL); final SyncConfiguration userConfig = configFactory .createSyncConfigurationBuilder(user, Constants.SYNC_SERVER_URL) .build(); final SyncConfiguration adminConfig = configFactory .createSyncConfigurationBuilder(adminUser, userConfig.getServerUrl().toString()) .build(); final CountDownLatch userInterruptLatch = new CountDownLatch(1); final CountDownLatch adminInterruptLatch = new CountDownLatch(1); Thread t = new Thread(new Runnable() { @Override public void run() { Realm userRealm = Realm.getInstance(userConfig); userRealm.beginTransaction(); userRealm.createObject(AllTypes.class); userRealm.commitTransaction(); SyncSession userSession = SyncManager.getSession(userConfig); try { userInterruptLatch.countDown(); userSession.downloadAllServerChanges(); } catch (InterruptedException ignored) { assertFalse(Thread.currentThread().isInterrupted()); } try { userSession.uploadAllLocalChanges(); } catch (InterruptedException e) { fail("Upload interrupted"); } userRealm.close(); Realm adminRealm = Realm.getInstance(adminConfig); SyncSession adminSession = SyncManager.getSession(adminConfig); try { adminInterruptLatch.countDown(); adminSession.uploadAllLocalChanges(); } catch (InterruptedException ignored) { assertFalse(Thread.currentThread().isInterrupted()); } try { adminSession.downloadAllServerChanges(); } catch (InterruptedException e) { fail("Download interrupted"); } adminRealm.refresh(); assertEquals(1, adminRealm.where(AllTypes.class).count()); adminRealm.close(); } }); t.start(); TestHelper.awaitOrFail(userInterruptLatch); t.interrupt(); TestHelper.awaitOrFail(adminInterruptLatch); t.interrupt(); t.join(); }

Target:
public void interruptWaits() throws InterruptedException { final SyncUser user = UserFactory.createUniqueUser(Constants.AUTH_URL); SyncUser adminUser = UserFactory.createAdminUser(Constants.AUTH_URL); final SyncConfiguration userConfig = configFactory .createSyncConfigurationBuilder(user, Constants.SYNC_SERVER_URL) .build(); final SyncConfiguration adminConfig = configFactory .createSyncConfigurationBuilder(adminUser, userConfig.getServerUrl().toString()) .build(); Thread t = new Thread(new Runnable() { @Override public void run() { Realm userRealm = Realm.getInstance(userConfig); userRealm.beginTransaction(); userRealm.createObject(AllTypes.class); userRealm.commitTransaction(); SyncSession userSession = SyncManager.getSession(userConfig); try { Thread.currentThread().interrupt(); userSession.downloadAllServerChanges(); } catch (InterruptedException ignored) { assertFalse(Thread.currentThread().isInterrupted()); } try { userSession.uploadAllLocalChanges(); } catch (InterruptedException e) { fail("Upload interrupted"); } userRealm.close(); Realm adminRealm = Realm.getInstance(adminConfig); SyncSession adminSession = SyncManager.getSession(adminConfig); try { Thread.currentThread().interrupt(); adminSession.uploadAllLocalChanges(); } catch (InterruptedException ignored) { assertFalse(Thread.currentThread().isInterrupted()); } try { adminSession.downloadAllServerChanges(); } catch (InterruptedException e) { fail("Download interrupted"); } adminRealm.refresh(); assertEquals(1, adminRealm.where(AllTypes.class).count()); adminRealm.close(); } }); t.start(); t.join(); }