void () { Alarm alarm = new Alarm(getTestRootDisposable()); AtomicInteger executed = new AtomicInteger(); int N = 100000; Set<Thread> used = ConcurrentCollectionFactory.createConcurrentSet(); for (int i = 0; i < N; i++) { alarm.addRequest(() -> { executed.incrementAndGet(); used.add(Thread.currentThread()); }, 10); } while (executed.get() != N) { UIUtil.dispatchAllInvocationEvents(); } if (used.size() > 10) { fail(used.size()+" threads created: "+used.stream().map(t->PerformanceWatcher.printStacktrace("", t, t.getStackTrace())).collect(Collectors.joining())); } }