public int getActiveConnections () { return pool.getActiveCount(); }
public void dump (PrintStream p, String indent) { String inner = indent + " "; p.println (indent + "<thread-pool name=\""+getName()+"\">"); if (!pool.ready()) p.println (inner + "<closed/>"); p.println (inner + "<jobs>" + getJobCount() + "</jobs>"); p.println (inner + "<size>" + getPoolSize() + "</size>"); p.println (inner + "<max>" + getMaxPoolSize() + "</max>"); p.println (inner + "<active>" + getActiveCount() + "</active>"); p.println (inner + "<idle>" + getIdleCount() + "</idle>"); p.println (inner + "<active>" + getActiveCount() + "</active>"); p.println (inner + "<pending>" + getPendingCount() + "</pending>"); p.println (indent + "</thread-pool>"); }
@Ignore @Test public void testConcurrentThreadAllocation() throws Throwable { ThreadPool pool = new ThreadPool(1, 200, "Test-ThreadPool"); Server server = new Server(pool); Thread serverThread = new Thread(server); serverThread.start(); serverThread.join(15000); assertEquals("pool.getActiveCount()", 100, pool.getActiveCount()); synchronized (server) { server.notifyAll(); } pool.close(); }
@Test @SuppressWarnings("deprecation") public void testIssue196 () { ThreadPool pool = new ThreadPool(10, 20, "thepool"); int available = pool.getAvailableCount(); int active = pool.getActiveCount(); long end = System.currentTimeMillis() + 10000L; // run for 10 seconds top int i = 0; while (active >= 0 && System.currentTimeMillis() < end) { while (available > 0) { pool.execute(() -> { }); available = pool.getAvailableCount(); } available = pool.getAvailableCount(); active = pool.getActiveCount(); } assertTrue ("Active should be >= 0 but it is " + active, active >= 0); }