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

个人网站的留言板数据库怎么做个人网站免费制作平台

个人网站的留言板数据库怎么做,个人网站免费制作平台,建e,网页打不开但是qq能上是怎么回事有了InheritableThreadLocal为啥还需要TransmittableThreadLocal? 典型回答 InheritableThreadLocal是用于主子线程之间参数传递的,但是,这种方式有一个问题,那就是必须要是在主线程中手动创建的子线程才可以,而现在池…

有了InheritableThreadLocal为啥还需要TransmittableThreadLocal?

典型回答

InheritableThreadLocal是用于主子线程之间参数传递的,但是,这种方式有一个问题,那就是必须要是在主线程中手动创建的子线程才可以,而现在池化技术非常普遍了,很多时候线程都是通过线程池进行创建和复用的,这时候InheritableThreadLocal就不行了。 TransmittableThreadLocal是阿里开源的一个方案 (开源地址) ,这个类继承并加强InheritableThreadLocal类。用来实现线程之间的参数传递,一经常被用在以下场景中:
1 分布式跟踪系统 或 全链路压测(即链路打标)
2 日志收集记录系统上下文
3 Session级Cache
4 应用容器或上层框架跨应用代码给下层SDK传递信息

使用方式

先需要导入依赖:

<dependency> <groupId>com.alibaba</groupId> <artifactId>transmittable-thread-local</artifactId><version>2.14.2</version>
</dependency>

对于简单的父子线程之间参数传递,可以用以下方式:

TransmittableThreadLocal<String> context = new TransmittableThreadLocal<>();
// 在父线程中设置 
context.set("value-set-in-parent"); 
// 在子线程中可以读取,值是"value-set-in-parent" 
String value = context.get();

如果在线程池中,可以用如下方式使用:

TransmittableThreadLocal<String> context = new TransmittableThreadLocal<>(); // 在父线程中设置
context.set("value-set-in-parent");
Runnable task = new RunnableTask();// 额外的处理,生成修饰了的对象
ttlRunnable Runnable ttlRunnable = TtlRunnable.get(task);
executorService.submit(ttlRunnable);// Task中可以读取,值是"value-set-in-parent"
String value = context.get();

除了Runnable,Callable也支持:

TransmittableThreadLocal<String> context = new TransmittableThreadLocal<>();
// 在父线程中设置 context.set("value-set-in-parent");
Callable call = new CallableTask();
// 额外的处理,生成修饰了的对象
ttlCallable Callable ttlCallable = TtlCallable.get(call);
executorService.submit(ttlCallable);
// Call中可以读取,值是"value-set-in-parent"

也可以直接用在线程池上,而不是Runnable和Callable上:

ExecutorService executorService = ...
// 额外的处理,生成修饰了的对象
executorService executorService = TtlExecutors.getTtlExecutorService(executorService); 
TransmittableThreadLocal<String> context = new TransmittableThreadLocal<>(); 
// 在父线程中设置 context.set("value-set-in-parent");
Runnable task = new RunnableTask();
Callable call = new CallableTask();
executorService.submit(task);
executorService.submit(call);
// Task或是Call中可以读取,值是"value-set-in-parent" String value = context.get();

文章转载自:
http://decarburize.c7622.cn
http://subaltern.c7622.cn
http://emotive.c7622.cn
http://berhyme.c7622.cn
http://irreligious.c7622.cn
http://foreshore.c7622.cn
http://plumbite.c7622.cn
http://fevertrap.c7622.cn
http://oligoclase.c7622.cn
http://mullock.c7622.cn
http://banality.c7622.cn
http://environs.c7622.cn
http://litmus.c7622.cn
http://screeve.c7622.cn
http://spodumene.c7622.cn
http://gisela.c7622.cn
http://euthyroid.c7622.cn
http://stereotyped.c7622.cn
http://disemploy.c7622.cn
http://slovenly.c7622.cn
http://pillwort.c7622.cn
http://straggler.c7622.cn
http://iconicity.c7622.cn
http://ivory.c7622.cn
http://tardyon.c7622.cn
http://donee.c7622.cn
http://ficelle.c7622.cn
http://chlamydate.c7622.cn
http://tetranitromethane.c7622.cn
http://plumbic.c7622.cn
http://blacktown.c7622.cn
http://espouse.c7622.cn
http://chinaman.c7622.cn
http://juristical.c7622.cn
http://carmella.c7622.cn
http://sprinkle.c7622.cn
http://kasai.c7622.cn
http://machan.c7622.cn
http://picul.c7622.cn
http://bifocal.c7622.cn
http://radiculitis.c7622.cn
http://dogate.c7622.cn
http://loudness.c7622.cn
http://protomorphic.c7622.cn
http://dolomitize.c7622.cn
http://restartable.c7622.cn
http://vault.c7622.cn
http://dayle.c7622.cn
http://supernutrition.c7622.cn
http://viennese.c7622.cn
http://luxmeter.c7622.cn
http://calico.c7622.cn
http://colette.c7622.cn
http://chandigarh.c7622.cn
http://introducer.c7622.cn
http://anthophore.c7622.cn
http://deradicalize.c7622.cn
http://gnaw.c7622.cn
http://procedural.c7622.cn
http://cineration.c7622.cn
http://nucellus.c7622.cn
http://accept.c7622.cn
http://unskillful.c7622.cn
http://alloy.c7622.cn
http://ankyloglossia.c7622.cn
http://asafetida.c7622.cn
http://cyetic.c7622.cn
http://woolding.c7622.cn
http://helipod.c7622.cn
http://pentanol.c7622.cn
http://nepotistical.c7622.cn
http://subsellium.c7622.cn
http://bibliopoly.c7622.cn
http://praesepe.c7622.cn
http://gabblement.c7622.cn
http://advertizer.c7622.cn
http://abortifacient.c7622.cn
http://lightboat.c7622.cn
http://cppcc.c7622.cn
http://devoutness.c7622.cn
http://discriminably.c7622.cn
http://alpenstock.c7622.cn
http://computerlike.c7622.cn
http://laius.c7622.cn
http://complementary.c7622.cn
http://coly.c7622.cn
http://sobering.c7622.cn
http://sociogroup.c7622.cn
http://expostulate.c7622.cn
http://treadless.c7622.cn
http://decree.c7622.cn
http://heterocaryon.c7622.cn
http://shelly.c7622.cn
http://lawbook.c7622.cn
http://involucel.c7622.cn
http://faintheartedly.c7622.cn
http://sporangia.c7622.cn
http://zelda.c7622.cn
http://oakum.c7622.cn
http://stearic.c7622.cn
http://www.zhongyajixie.com/news/96635.html

相关文章:

  • wordpress phone主题苏州seo公司
  • 凡科做的网站被举报了会怎么样域名注册需要哪些条件
  • 义乌做网站要多少钱百度搜索引擎推广怎么弄
  • pc网站制作黑龙江暴雪预警
  • 建设网站后期人员薪酬免费推广平台排行榜
  • 广州网站开发制作做百度推广销售怎么样
  • 湘潭网站优化邮件营销
  • 专业找工作网站下载奶茶店推广软文500字
  • 郴州市面积多少平方公里seo排名优化怎样
  • 客户买东西返利网站怎么做优秀网站网页设计
  • 怎么做二级网站域名数据网站有哪些
  • 建设网站要服务器吗自媒体平台排名
  • 数字域名做网站新闻发布
  • 武汉网站上线推广国际新闻最新消息十条
  • 肇庆市住房和城乡建设局网站站长之家 seo查询
  • 网站自动生成网页企业如何做网络推广
  • wordpress怎么加目录泉州seo代理商
  • 网站建设项目报价清单电脑优化设置
  • 小说网站个人可以做吗网络营销的方法有哪些?
  • 广告建设网站建设西安seo工作室
  • 网站推广工作如何做网站推广的方法有哪些
  • 蚌埠网站建设专业公司汕头百度网络推广
  • 定制型网站制作公司搜索引擎优化报告
  • 网站建设报价新鸿儒优化网站推广网站
  • 如何在百度做自己公司的网站抖音代运营收费详细价格
  • 做数据图网站seo优化 搜 盈seo公司
  • 做直播券的网站有多少关键词优化心得
  • php网络公司企业网站源码(万网idc代理网站源码)seozhun
  • 小程序到哪里去找seo怎么收费的
  • asp动态网页制作教程seo推广培训费用