1、线程池配置文件
#一般采用properties配置
threadpool.corePoolSize=20
threadpool.maxPoolSize=50
threadpool.queueCapacity=20000
2、spring配置文件
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="${threadpool.corePoolSize}" />
<property name="maxPoolSize" value="${threadpool.maxPoolSize}" />
<property name="queueCapacity" value="${threadpool.queueCapacity}" />
<property name="threadNamePrefix" value="resume_" />
</bean>
3、java代码中注入线程池
@Autowired
private ThreadPoolTaskExecutor taskExecutor;
启线程:
taskExecutor.execute(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
}
});