void () { AtomicInteger count = new AtomicInteger(); Callable<String> computation = () -> { if (count.incrementAndGet() < 10) { throw new ServiceNotReadyException(); } return "x"; }; CancellablePromise<String> future1 = ReadAction.nonBlocking(computation).submit(AppExecutorUtil.getAppExecutorService()); assertEquals("x", PlatformTestUtil.waitForFuture(future1, 1000)); assertEquals(10, count.get()); count.set(0); Future<String> future2 = ApplicationManager.getApplication().executeOnPooledThread( () -> ReadAction.nonBlocking(computation).executeSynchronously()); assertEquals("x", PlatformTestUtil.waitForFuture(future2, 1000)); assertEquals(10, count.get()); }