JAVA 并发编程-应用篇
提到java多线程不免有些人会头大。非常多概念都是非常理解可是真正到了实战的时候又是不知道怎样操作了。以下就结合实际项目来说说多线程的应用。
业务需求:
举例:批量插入10万条用户的相关活动优惠券
操作方式:使用固定10个大小的线程池来做。并每次处理1000条插入数据
线程类:注实现Callable<Integer>接口的是能得到返回值的线程类
public class InsertBatchThread implements Callable<Integer> {private int vdate;
private int uid;
private int count;
private FundsInfoMapper fundsInfoMapper;
private WmpsDayInterMapper wmpsDayInterMapper;
private DataSource dataSource;public WmpsDayInterMapper getWmpsDayInterMapper() {
if (null == wmpsDayInterMapper) {
synchronized (this) {
if (null == wmpsDayInterMapper) {
wmpsDayInterMapper = SpringContextUtils.getBean("wmpsDayInterMapper");
}
}
}
return wmpsDayInterMapper;
}public FundsInfoMapper getProCommFundsInfoMapper() {
if (null == fundsInfoMapper) {
synchronized (this) {
最新文章
- qlikview 扩展插件制作教程-EchartsGeoMap
- adb connect 出现timeout的处理方式
- 使用VBScript实现设置系统环境变量的小程序
- undefined symbol libiconv_open 完全解决方案
- 发送广播BroadcastReceiver
- outlook圆角table
- ubuntu下apt-get update出现hash校验和错误
- iTween基础之Punch(摇晃)
- msp时钟设置程序
- 华为RH8100V3RAID 10配置
- 搭建web服务器-tomcat+apache+mysql+eclipse
- mysql5.7连接不上可能的问题(针对新安装的mysql5.7可能出现的问题)
- jqurey实现点赞特效
- Loadrunner登录判断
- Selenium自动化测试,接口自动化测试开发,性能测试从入门到精通
- APK骨架分析
- loki grafana 团队开源的,类似Prometheus 的log 系统
- 对某个区间操作(sort,stable_sort,parital_sort,parital_sort_copy,nth_element,is_sorted)
- python is 和 == 和=
- Docker常用操作命令