首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关于这篇文章的问题

关于这篇文章的问题
EN

Stack Overflow用户
提问于 2016-03-15 03:31:46
回答 1查看 32关注 0票数 0

我看到了这个:

代码语言:javascript
复制
Pattern #2: one-time safe publication
The visibility failures that
are possible in the absence of synchronization can get even trickier
to reason about when writing to object references instead of primitive
values. In the absence of synchronization, it is possible to see an
up-to-date value for an object reference that was written by another
thread and still see stale values for that object's state. (This
hazard is the root of the problem with the infamous
double-checked-locking idiom, where an object reference is read
without synchronization, and the risk is that you could see an
up-to-date reference but still observe a partially constructed object
through that reference.)*

来自易失性

我很困惑:

  1. 什么是“原始价值”
  2. 原因:“查看由另一个线程编写的对象引用的最新值,但仍然看到该对象状态的陈旧值”。
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-15 04:17:45

1)原语值不是整数、布尔、浮点等对象,只需记住这些对象的等价性,如整数、布尔等。

2)线程可能会看到更新的对象引用,但该对象可能没有被完全初始化。例如,当这个线程获得对象的新更新引用时,如果构造函数尚未完成,就可能发生这种情况.这可能很复杂,但可能会发生在一些JVM实现中。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36002210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档