V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  azygote  ›  全部回复第 1 页 / 共 4 页
回复总数  72
1  2  3  4  
2021-02-15 19:46:23 +08:00
回复了 ChenXuting 创建的主题 汽车 问卷调查系列, V 友们都开什么车?
26 C 系
2020-11-19 15:40:04 +08:00
回复了 levizheng 创建的主题 Java 咨询一个关于 synchronized 问题
@levizheng 仔细读这段 "Due to the semantics of some programming languages, the code generated by the compiler is allowed to update the shared variable to point to a partially constructed object before A has finished performing the initialization. For example, in Java if a call to a constructor has been inlined then the shared variable may immediately be updated once the storage has been allocated but before the inlined constructor initializes the object.[6]"
如果不加 volatile, 有个线程对 uniqueInstance 初始化到一半,另外一个线程执行到 synchronized 外面的那个 if (uniqueInstance == null) 是可能返回 false 的,也就读到的不是 null,而是一个初始化了一半的对象。
2020-11-19 15:27:36 +08:00
回复了 aiqier 创建的主题 程序员 Java 的 web 服务会在什么情况下读磁盘?
如果日志框架是 log4j/log4j2, 然后启用了 rolling file appender 的话,是会向硬盘写日志的
2020-11-19 15:15:35 +08:00
回复了 levizheng 创建的主题 Java 咨询一个关于 synchronized 问题
volatile 的作用主要是为了 synchronized 外面那个 if 的。如果不加 volatile 的话,会出现一个情况:有一个线程正在对 uniqueInstance 赋值,由于没有 volatile 关键字,uniqueInstance 可能返回一个初始化一半了的对象,然后这时恰好另外一个线程正好执行到 if (uniqueInstance == null),得到结果为 false 然后直接返回, 但实际上这个 uniqueInstance 读到的值并没有初始化完成,导致返回了初始化了一半的对象,最后造成程序 crash 。

引自维基百科: https://en.wikipedia.org/wiki/Double-checked_locking

Intuitively, this algorithm seems like an efficient solution to the problem. However, this technique has many subtle problems and should usually be avoided. For example, consider the following sequence of events:

Thread A notices that the value is not initialized, so it obtains the lock and begins to initialize the value.

Due to the semantics of some programming languages, the code generated by the compiler is allowed to update the shared variable to point to a partially constructed object before A has finished performing the initialization. For example, in Java if a call to a constructor has been inlined then the shared variable may immediately be updated once the storage has been allocated but before the inlined constructor initializes the object.[6]

Thread B notices that the shared variable has been initialized (or so it appears), and returns its value. Because thread B believes the value is already initialized, it does not acquire the lock. If B uses the object before all of the initialization done by A is seen by B (either because A has not finished initializing it or because some of the initialized values in the object have not yet percolated to the memory B uses (cache coherence)), the program will likely crash.
2020-09-24 16:44:59 +08:00
回复了 selfcreditgiving 创建的主题 问与答 什么情况,占用内存 2 个 G! springboot 这么耗资源嘛
估计是内存泄露了
2020-07-10 15:50:35 +08:00
回复了 JasonLaw 创建的主题 Java Jackson 序列化时,如何将 final 类型的类型信息保存起来?
你需要这个包 https://github.com/FasterXML/jackson-datatypes-collections 来进行 Guava 里面的一些 Collections 类的序列 /反序列化
2020-02-10 15:35:19 +08:00
回复了 dik88chen 创建的主题 问与答 想问一下大家, 2020 年 IOS 用户大家在用哪个导航 APP。
基本使用 Waze, 偶尔用 Google Map, 坐标美帝
2018-11-28 01:41:24 +08:00
回复了 Vegetables 创建的主题 算法 如何在 数组 [0, 1, 2, 3, ..., n] 中选取 m 个不相邻的整数?
回溯法
2018-09-30 00:52:00 +08:00
回复了 tsukiikekaoru 创建的主题 MacBook 你萌的 winrar 在虚拟下能正常使用吗
bandizip 了解一下?
2018-07-21 01:34:43 +08:00
回复了 lzbnet 创建的主题 Netflix 想注册一个 netflix 帐户,但奈何支付总不成功,是为何?
@lzbnet 如果是双币卡的话绑定 paypal 需要改一下支付通道,因为国区 paypal 绑卡默认走银联,需要手动改成 Visa 或者 MasterCard
2018-07-20 23:08:00 +08:00
回复了 lzbnet 创建的主题 Netflix 想注册一个 netflix 帐户,但奈何支付总不成功,是为何?
亲测 netflix 用国区 paypal 支付没有问题
2018-07-18 22:29:12 +08:00
回复了 shazh520 创建的主题 Java spring boot 2.0 参数绑定好像不一样了
POST 的话不需要 @RequestParam 的吧
2018-06-28 23:11:22 +08:00
回复了 kefengong 创建的主题 问与答 夏天有哪些不错的冷饮推荐?
冰美式咖啡
2018-06-22 22:23:48 +08:00
回复了 hansonwang99 创建的主题 程序员 SpringBoot 热部署加持
devtools 没 jrebel 好用
2018-05-23 15:21:55 +08:00
回复了 rogwan 创建的主题 问与答 有好用的团队 Wiki 推荐的吗?
confluence + JIRA
2018-04-05 21:56:35 +08:00
回复了 AnthonyLau 创建的主题 Python 想学 Python ,哪本书入门好一点
《 Fluent Python 》
2018-03-26 19:14:56 +08:00
回复了 DXDE443 创建的主题 Java 请教大佬们一个关于 springmvc 的一个简单问题
你这里 Job 对象类似一个容器,这个对象的每个字段对应你 get 请求的键值对,这个设计很合理,因为你 get 请求传参数肯定一个参数一个参数中间加&来传的,不存在直接传一个对象过来。
1  2  3  4  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4897 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms · UTC 09:43 · PVG 17:43 · LAX 02:43 · JFK 05:43
Developed with CodeLauncher
♥ Do have faith in what you're doing.