void (final int readIterations, final int writeIterations, int expectedMs) { NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); // someone might've submitted a task depending on app events which we disable now final ApplicationImpl application = (ApplicationImpl)ApplicationManager.getApplication(); Disposable disposable = Disposer.newDisposable(); application.disableEventsUntil(disposable); ThreadingAssertions.assertEventDispatchThread(); try { PlatformTestUtil.startPerformanceTest("lock/unlock "+getTestName(false), expectedMs, () -> { final int numOfThreads = JobSchedulerImpl.getJobPoolParallelism(); List<Job<Void>> threads = new ArrayList<>(numOfThreads); for (int i = 0; i < numOfThreads; i++) { Job<Void> thread = JobLauncher.getInstance().submitToJobThread(() -> { assertFalse(application.isReadAccessAllowed()); for (int i1 = 0; i1 < readIterations; i1++) { application.runReadAction(() -> { }); } }, null); threads.add(thread); } for (int i = 0; i < writeIterations; i++) { ApplicationManager.getApplication().runWriteAction(() -> { }); } waitWithTimeout(threads); }).assertTiming(); } finally { Disposer.dispose(disposable); } }