提到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) {

最新文章

  1. qlikview 扩展插件制作教程-EchartsGeoMap
  2. adb connect 出现timeout的处理方式
  3. 使用VBScript实现设置系统环境变量的小程序
  4. undefined symbol libiconv_open 完全解决方案
  5. 发送广播BroadcastReceiver
  6. outlook圆角table
  7. ubuntu下apt-get update出现hash校验和错误
  8. iTween基础之Punch(摇晃)
  9. msp时钟设置程序
  10. 华为RH8100V3RAID 10配置
  11. 搭建web服务器-tomcat+apache+mysql+eclipse
  12. mysql5.7连接不上可能的问题(针对新安装的mysql5.7可能出现的问题)
  13. jqurey实现点赞特效
  14. Loadrunner登录判断
  15. Selenium自动化测试,接口自动化测试开发,性能测试从入门到精通
  16. APK骨架分析
  17. loki grafana 团队开源的,类似Prometheus 的log 系统
  18. 对某个区间操作(sort,stable_sort,parital_sort,parital_sort_copy,nth_element,is_sorted)
  19. python is 和 == 和=
  20. Docker常用操作命令

热门文章

  1. 1.2(SQL学习笔记)高级数据过滤
  2. java多线程加锁是对谁加锁?
  3. Tesseract训练中文字体识别
  4. Xcode8从相册选图片
  5. iOS:导航控制器侧滑出栈实现
  6. Delphi中Frame的使用方法(2)
  7. flask上传文件时request.files为空的解决办法
  8. asp.net mvc 3 配置全局错误处理 Web.config中设置CustomError
  9. ubuntu创建sudo 用户
  10. php 获取/设置用户訪问页面语言类