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>"); }
@Test public void testReady() throws Throwable { boolean result = new BlockingQueue().ready(); assertTrue("result", result); }
public synchronized void execute(Runnable action) throws Closed { if (!pool.ready()) throw new Closed(); if (++jobs % this.maxPoolSize == 0 || pool.consumerCount() <= 0) supervise(); if (running < maxPoolSize && pool.consumerDeficit() >= 0) { new PooledThread().start(); running++; } available--; pool.enqueue (action); } public void dump (PrintStream p, String indent) {
public void run () { String name = getName(); try { while (pool.ready()) { Object job = pool.dequeue(); if (job instanceof Runnable) {
@Test public void testClose() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.close(); assertFalse("blockingQueue.ready()", blockingQueue.ready()); }
@Test public void testReady1() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); blockingQueue.close(); boolean result = blockingQueue.ready(); assertFalse("result", result); }
@Test public void testConstructor() throws Throwable { BlockingQueue blockingQueue = new BlockingQueue(); assertEquals("blockingQueue.consumerCount()", 0, blockingQueue.consumerCount()); assertTrue("blockingQueue.ready()", blockingQueue.ready()); assertEquals("blockingQueue.getQueue().size()", 0, blockingQueue.getQueue().size()); }