1 22 package org.jboss.util.threadpool; 23 24 import EDU.oswego.cs.dl.util.concurrent.PooledExecutor; 25 import EDU.oswego.cs.dl.util.concurrent.Channel; 26 27 49 public class MinPooledExecutor extends PooledExecutor 50 { 51 53 54 56 57 protected int keepAliveSize; 58 59 61 63 68 public MinPooledExecutor(int poolSize) 69 { 70 super(poolSize); 71 } 72 73 79 public MinPooledExecutor(Channel channel, int poolSize) 80 { 81 super(channel, poolSize); 82 } 83 84 86 89 public int getKeepAliveSize() 90 { 91 return keepAliveSize; 92 } 93 94 97 public void setKeepAliveSize(int keepAliveSize) 98 { 99 this.keepAliveSize = keepAliveSize; 100 } 101 102 104 protected Runnable getTask() throws InterruptedException 105 { 106 Runnable task = super.getTask(); 107 while (task == null && keepAlive()) 108 { 109 task = super.getTask(); 110 } 111 return task; 112 } 113 114 116 118 124 protected synchronized boolean keepAlive() 125 { 126 if (shutdown_) 127 return false; 128 129 return poolSize_ <= keepAliveSize; 130 } 131 132 134 } 136 | Popular Tags |