資源簡介
小游戲超級瑪麗項目.
代碼片段和文件信息
package?com.brackeen.javagamebook.util;
import?java.util.linkedList;
/**
????A?thread?pool?is?a?group?of?a?limited?number?of?threads?that
????are?used?to?execute?tasks.
*/
public?class?ThreadPool?extends?ThreadGroup?{
????private?boolean?isAlive;
????private?linkedList?taskQueue;
????private?int?threadID;
????private?static?int?threadPoolID;
????/**
????????Creates?a?new?ThreadPool.
????????@param?numThreads?The?number?of?threads?in?the?pool.
????*/
????public?ThreadPool(int?numThreads)?{
????????super(“ThreadPool-“?+?(threadPoolID++));
????????setDaemon(true);
????????isAlive?=?true;
????????taskQueue?=?new?linkedList();
????????for?(int?i=0;?i ????????????new?PooledThread().start();
????????}
????}
????/**
????????Requests?a?new?t
評論
共有 條評論