private static void checkSufficientThreads(Connector connector, String name) { if (connector == null) { return; } Executor executor = connector.getExecutor(); if (executor instanceof ThreadPool) { ThreadPool queuedThreadPool = (ThreadPool) executor; checkState( !queuedThreadPool.isLowOnThreads(), "insufficient threads configured for %s connector", name); } }
@Test public void testThreadPoolMXBean() throws Exception { final int threadCount = 100; final long requestCount = 100; final String requestUrl = jetty.getBaseUri().resolve("d.txt").toASCIIString(); final CountDownLatch gate = new CountDownLatch(threadCount); ThreadPool worker = new ExecutorThreadPool(threadCount, threadCount, 60, TimeUnit.SECONDS); for (int idx = 0; idx < threadCount; idx++) { worker.dispatch( new Runnable() { public void run() { runTest(requestUrl, requestCount); gate.countDown(); } }); Thread.sleep(100); } gate.await(); assertTrue(true); }