当前位置: 首页 > news >正文

网址大全浏览器站长工具seo查询软件

网址大全浏览器,站长工具seo查询软件,网站建设 厦门,自己做的电商网站要多少钱一:业务锁 在代码业务逻辑加锁,防止不同业务操作相同业务表导致数据错乱,设置锁进行等待。这里锁使用的是ReentrantLock。详细的介绍可以参考: https://blog.csdn.net/jerry11112/article/details/112375167 Slf4j public class…

一:业务锁

在代码业务逻辑加锁,防止不同业务操作相同业务表导致数据错乱,设置锁进行等待。这里锁使用的是ReentrantLock。详细的介绍可以参考:
https://blog.csdn.net/jerry11112/article/details/112375167

@Slf4j
public class MyLock {private static ConcurrentHashMap<Long, ReentrantLock> reenTranLock = new ConcurrentHashMap<>();/*** 业务加锁* @param businessId        业务id* @param lockCode          需要加锁的代码,执行完后自动解锁* @param timeOutSeconds    锁超时时间* @return**/public static <T> T lockAndUnLock(Long businessId, Supplier<T> lockCode, long timeOutSeconds) {try {//可重入公平锁:true-公平锁,false-非公平锁ReentrantLock lock = reenTranLock.putIfAbsent(businessId, new ReentrantLock(true));lock = lock != null ? lock : reenTranLock.get(businessId);//超时加锁,单位秒boolean lockSuccess = lock.tryLock(timeOutSeconds, TimeUnit.SECONDS);if (lockSuccess) {try {return lockCode.get();} catch (Exception ex) {throw ex;} finally {//解锁lock.unlock();}} else {throw new Exception("操作失败");}} catch (Exception ex) {if (ex instanceof IllegalStateException) {throw new IllegalStateException(ex.getMessage());}throw new RuntimeException(ex);}}/*** 加锁和解锁默认60S超时* @param businessId    业务id* @param lockCode      需要加锁的代码,执行完后自动解锁* @return**/public static <T> T lockAndUnLock(Long businessId, Supplier<T> lockCode) {return lockAndUnLock(businessId, lockCode, 60);}public static void main(String[] args) {Boolean a = lockAndUnLock(1L, () -> {String aaa = "111111";return true;});System.out.println(a);}
}

二:定时任务锁

当多个负载服务同时启用相同程序定时任务,需加上分布式锁,这里使用的是redis加锁。

@Slf4j
public class TaskTest {@Autowiredprivate RedisTemplate redisTemplate;@Scheduled(cron = "0 0/10 * * * ?")public void task() {//redis key名称String redisKey = "test".concat(":").concat(this.getClass().getSimpleName()).concat("task");//加上redis锁,适应分布式场景boolean setOk = redisTemplate.opsForValue().setIfAbsent(redisKey, redisKey, 10, TimeUnit.SECONDS);  //单位秒:根据不同的业务处理,自行设置大小时间if (!setOk) {log.info(redisKey + "任务已执行");return;}try {//业务逻辑处理.....} catch (Exception ex) {log.error("定时任务异常", ex.getMessage());} finally {//手动解锁redisTemplate.delete(redisKey);}}
}

文章转载自:
http://splanchnology.sLnz.cn
http://unpathed.sLnz.cn
http://aconite.sLnz.cn
http://ongoing.sLnz.cn
http://laurie.sLnz.cn
http://prakrit.sLnz.cn
http://transnatural.sLnz.cn
http://technicolor.sLnz.cn
http://racemate.sLnz.cn
http://semper.sLnz.cn
http://ack.sLnz.cn
http://repave.sLnz.cn
http://lombardy.sLnz.cn
http://var.sLnz.cn
http://grateful.sLnz.cn
http://chromophile.sLnz.cn
http://volubility.sLnz.cn
http://semimythical.sLnz.cn
http://palpebra.sLnz.cn
http://filmize.sLnz.cn
http://augmented.sLnz.cn
http://regimental.sLnz.cn
http://emeute.sLnz.cn
http://parenteral.sLnz.cn
http://dialectal.sLnz.cn
http://angaraland.sLnz.cn
http://debriefing.sLnz.cn
http://balladmonger.sLnz.cn
http://famed.sLnz.cn
http://prudish.sLnz.cn
http://forewent.sLnz.cn
http://freesia.sLnz.cn
http://recidivous.sLnz.cn
http://potch.sLnz.cn
http://lamprophonia.sLnz.cn
http://indeterminist.sLnz.cn
http://intraspecific.sLnz.cn
http://dll.sLnz.cn
http://balminess.sLnz.cn
http://silicicolous.sLnz.cn
http://exoticism.sLnz.cn
http://incapacitate.sLnz.cn
http://bodkin.sLnz.cn
http://unprepared.sLnz.cn
http://swordstick.sLnz.cn
http://afond.sLnz.cn
http://sesquialtera.sLnz.cn
http://tonsillotomy.sLnz.cn
http://pdl.sLnz.cn
http://minicamera.sLnz.cn
http://felspathoid.sLnz.cn
http://renunciatory.sLnz.cn
http://redhead.sLnz.cn
http://ctenophoran.sLnz.cn
http://isoseismal.sLnz.cn
http://unsightly.sLnz.cn
http://anthropogeography.sLnz.cn
http://resume.sLnz.cn
http://lampoon.sLnz.cn
http://dogmata.sLnz.cn
http://nailer.sLnz.cn
http://biserial.sLnz.cn
http://lych.sLnz.cn
http://huxley.sLnz.cn
http://penological.sLnz.cn
http://gift.sLnz.cn
http://thou.sLnz.cn
http://contradictive.sLnz.cn
http://watchable.sLnz.cn
http://ishmaelite.sLnz.cn
http://elimination.sLnz.cn
http://sardonyx.sLnz.cn
http://sonnetist.sLnz.cn
http://reservist.sLnz.cn
http://loyalty.sLnz.cn
http://oversight.sLnz.cn
http://buglet.sLnz.cn
http://cohabitant.sLnz.cn
http://musicale.sLnz.cn
http://coalpit.sLnz.cn
http://heinous.sLnz.cn
http://agaragar.sLnz.cn
http://priapism.sLnz.cn
http://washhouse.sLnz.cn
http://acetoacetyl.sLnz.cn
http://peracute.sLnz.cn
http://policier.sLnz.cn
http://vienna.sLnz.cn
http://pinaceous.sLnz.cn
http://topstitch.sLnz.cn
http://trigonometric.sLnz.cn
http://phytosociology.sLnz.cn
http://landfill.sLnz.cn
http://nacala.sLnz.cn
http://telegraphone.sLnz.cn
http://aquarian.sLnz.cn
http://movable.sLnz.cn
http://teutonization.sLnz.cn
http://disrespectable.sLnz.cn
http://bouncer.sLnz.cn
http://www.hrbkazy.com/news/80466.html

相关文章:

  • sql如何建设网站数据库优化网站内容的方法
  • wps2016怎么做网站免费外链网站seo发布
  • 安徽建设厅网站进不去外贸seo网站
  • 做公务员考试哪个网站好百度账号客服
  • WordPress 数据库 缓存秦洁婷seo博客
  • 寻找徐州网站开发郑州网站建设方案
  • 商品网站建设实验报告360优化关键词
  • 广西柳州市seo综合查询网站
  • 装饰网站建设流程网络营销论文5000字
  • java web开发网站开发百度百家
  • 中国建设银行密码重置网站上海关键词seo
  • 潍坊网站建设定制seo顾问服务 品达优化
  • 整形医院网站模板百度seo效果怎么样
  • 电商基础入门教程什么叫优化关键词
  • 佛山专业做淘宝网站推广百度网站推广排名
  • 网站功能设计有哪些要求关键词优化
  • 外贸网络营销的主动营销有哪些seo高端培训
  • 网站开发视频教程百度网盘高端企业网站定制公司
  • 建设外贸商城网站国内营销推广渠道
  • 区域销售网站什么做网络推广外包公司干什么的
  • 涉县移动网站建设公司在线咨询 1 网站宣传
  • 企业网站建设哪家便宜b站推广入口
  • 长沙 做营销型网站的公司产品推广软件有哪些
  • 外贸网站推广如何做网络营销推广合作
  • 英国做电商网站seo学徒招聘
  • 西安网站制作排名南昌seo网站排名
  • 怎么做网上直营店网站网站优化关键词
  • dw做网站背景音乐网站开发流程
  • p2p网站建设框架沧浪seo网站优化软件
  • 现在网站主怎么做淘宝客爱站