Code
package com.tender.nmem.eris.drawexpert.service.impl;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.collections.map.ListOrderedMap;
/**
* 类:线程池类,控制程序线程实例个数,并实例线程
* @author yangtb
* 时间:2009/09/14
*
*/
public class ThreadPool {
private ExecutorService exe=null;//线程池
public ThreadPool(int pool_size)
{
exe=Executors.newFixedThreadPool(pool_size);//创建线程池
System.out.println("the server is ready");
}
/**
* 运行循环实例线程,根据要实例的线程个数,传入条件ID
* @param worknum
*/
public void server(int worknum,String id)
{
int i=0;
while(i<worknum)
{
//实例指定个线程
WorkerThreadImpl t = new WorkerThreadImpl(id);
exe.execute(t);//放入线程池
i++;
}
}
}
package com.tender.nmem.eris.drawexpert.service.impl;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.collections.map.ListOrderedMap;
/**
* 类:线程池类,控制程序线程实例个数,并实例线程
* @author yangtb
* 时间:2009/09/14
*
*/
public class ThreadPool {
private ExecutorService exe=null;//线程池
public ThreadPool(int pool_size)
{
exe=Executors.newFixedThreadPool(pool_size);//创建线程池
System.out.println("the server is ready");
}
/**
* 运行循环实例线程,根据要实例的线程个数,传入条件ID
* @param worknum
*/
public void server(int worknum,String id)
{
int i=0;
while(i<worknum)
{
//实例指定个线程
WorkerThreadImpl t = new WorkerThreadImpl(id);
exe.execute(t);//放入线程池
i++;
}
}
}