spring4 线程池:把需要执行的thread放入线程池中:缓冲队列
public class test {
public static void main(string[] args) {
applicationcontext app = new classpathxmlapplicationcontext("applicationcontext.xml");
threadpooltaskexecutor pool=(threadpooltaskexecutor)app.getbean("taskexecutor");
testspringthreadpool(pool);
}
static void testspringthreadpool(threadpooltaskexecutor pool){
pool.execute(new testthread(0));
for(int i=1;i<10000;i ){
pool.execute(new testthread(i));
}
}
static class testthread implements runnable{
private int num;
public testthread(int num){
this.num=num;
}
public void run() {
try {
thread.sleep(200);
} catch (interruptedexception e) {
e.printstacktrace();
}
system.out.println("thread " num);
}
}
相关推荐
activemq与spring线程池整合的一个实例。 lib库没有上传。 对于实例的讲解,在竹子的论坛有我对这个实例的帖子(http://www.java2000.net/viewthread.jsp?tid=1167) lib中包含: apache-activemq-4.1.1.jar ...
springmvc spring线程池处理http并发请求数据同步控制问题
线程池例子线程池例子线程池例子线程池例子
数据库连接是一种关键的有限的昂贵的资源,这一点在多用户网页应用程序中体现的尤为突出。对数据库连接的管理能显著影响到整个应用的伸缩性和健壮性,影响到程序的性能指标。
spring 线程池 demo
spring中的同步执行器 1. synctaskexecutor:同步可以用synctaskexecutor,但这个可以说不算一个线程池,因为还在原线程执行。这个类没有实现异步调用,只是一个同步操作。 2.也可以用threadpooltaskexecutor结合...
最代码,http://www.zuidaima.com/share/1724478138158080.htm 的代码及例子
使用spring线程池多线程并发处理大批量数据,解决io效率问题。
主要介绍了jdk线程池和spring线程池的使用实例解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
null 博文链接:https://bijian1013.iteye.com/blog/2368708
本篇文章主要介绍了spring线程池threadpooltaskexecutor配置详情,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
今天小编就为大家分享一篇关于spring线程池threadpoolexecutor配置并且得到任务执行的结果,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
spring 简介,spring事务控制,spring注解,spring定时调用,spring线程池,springmvc,quartz,springsecurity,的详细解析文档
spring3.2.6定时任务 线程池,实现系统后台任务多线程处理
主要介绍了线程池中使用spring aop事务增强,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
activemq 配置说明与activemq入门讲解
java线程池处理多并发,所有进程执行完后再统一处理结果线程池配置类多线程并行demo 线程池配置类 import org.springframework.beans.factory.annotation.value; import org.springframework.context.annotation....
主要介绍了浅谈spring 线程异步执行,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
主要介绍了java的线程池框架及线程池的原理的相关资料,需要的朋友可以参考下