failing to do so could result in data corruption and other undesirable consequences
You should avoid the temptation to think that there are "special" situations in which this rule does not apply.
data corruption 数据腐烂
If multiple threads access the same mutable state variable without appropriate synchronization, your program is broken. There are three ways to fix it:
Don't share the state variable across threads;
Make the state variable immutable; or
Use synchronization whenever accessing the state variable.
it may be necessary in these cases to compromise the rules of good design for the sake of performance or for the sake of
backward compatibility with legacy code.
for the sake of 为了
compromise n. 妥协, 折中方法 vi. 折中解决 vt. 连累, 危害, 损害
Sometimes abstraction and encapsulation are at odds with performance
at odds with 与…不和, 与…争吵
Even then, pursue optimization only if your performance measurements and requirements tell you that you must, and if those same measurements tell you that your optimizations actually made a difference under realistic conditions.
make a difference 紧要
even then 尽管那样
it is susceptible to lost updates
be susceptible to v. 对…敏感,可被…
returning the same value from multiple invocations could cause serious data integrity problems.
data integrity 数据完整性
An atomic operation is one that is atomic with respect to all operations
with respect to 关于, (至于)谈到
To ensure thread safety, check-then-act operations (like lazy initialization) and read-modify-write operations (like increment) must always be atomic.
they lay the foundation for building thread-safe classes and safely structuring concurrent applications using the java.util.concurrent library classes.
lay the foundation for 给…打下基础,为…奠定基础
NoVisibility demonstrated one of the ways that insufficiently synchronized programs can cause surprising results: stale data.
stale data 过期数据
Reading data without synchronization is analogous to using the READ_UNCOMMITTED isolation level in a database, where you are willing to trade accuracy for performance. However, in the case of unsynchronized reads, you are trading away a greater degree of accuracy, since the visible value for a shared variable can be arbitrarily stale.
be analogous to 类似于…,与…相似
trade for 用…换…
trade away 卖掉
This safety guarantee is called out-of-thin-air safety.
out of thin air 无中生有, 突然出现
Locking is not just about mutual exclusion; it is also about memory visibility. To ensure that all threads see the most up-to-date values of shared mutable variables, the reading and writing threads must synchronize on a common lock.
mutual exclusion (噬菌体)互斥现象
The most blatant form of publication is to store a reference in a public static field
blatant 1 吵嚷的;喧哗的 2 极明显的,公然的 3 无耻的,露骨的 4 刺眼的;炫耀的 dv. 无耻地,露骨地
UnsafeStates in Listing 3.6 publishes the supposedly private array of state abbreviations.
abbreviation 缩写; 缩写词
the states array has escaped its intended scope, because what was supposed to be private state has been effectively made public.
be supposed to v. 应该,被期望
Thread Confinement
confinement n. 1 限制,被监禁 2 分娩
Ad-hoc Thread Confinement
ad hoc adv.&adj. 1 为了某一特别场合或用途的(地),特别的(地),专门的(地) 2 机动的;临时的;特设的
Because of its fragility, ad-hoc thread confinement should be used sparingly
sparingly adv. 1 节俭地;爱惜地 2 保守地;谨慎地 3 缺少地 4 仁慈地
immutable objects cannot be subverted in this manner by malicious or buggy code,
subvert vt. 1 颠覆, 破坏(政治制度、宗教信仰等) 2 使(某人)道德败坏或不忠
More often than not, a cross join produces a result set containing misleading rows. Therefore, unless you are sure that you want a Cartesian product, don't use a cross join.
more often than not 往往, 多半
In this regard, it acts like a temporary table with statement scope
in this regard 在这点上
NULL can be used in place of a value of any data type
in place of 代替
Other than the union compatibility conditions discussed at the beginning of the chapter
other than 除了 绝不是
Over the past 15 years, hard disk capacities have evolved from around 10 MB to over 100 GB
evolve from 从…逐渐形〔发展〕成
As you’ve seen in the previous chapters, the beauty of this technique is that all
the service details are completely transparent to bean clients and even to bean
developers.
The System Task Scheduler, generally lesser known, is the Microsoft Windows counterpart of cron
counterpart 与对方地位相当的人, 与另一方作用相当的物
1)“Out of box”用于描述某种不确定的事件。常常作为副词来形容某种观点的不确定性。据说这个词同20世纪早期的英国数学家亨利?恩斯特?杜德耐解答一个著名数学谜语的思路相关。题目要求用四条直线连接平面上三乘三分布的九个点,要求一笔连成,也就是在画线的时候笔不能离开纸面。解决这个数学问题的关键在于要克服传统的在三乘三边界内画点的思想,如果将线连接到边界之外,那么问题可以迎刃而解,这样就产生了“Out of box”这个词。相应的,将思维受限这种情况称为“boxed-in”。在IT领域,节奏变化很快,因此每个人都在寻找“Out of box”的思维方式,尝试创新。
用“In the box”表示某种确定的事情。比如,最近有一篇文章讨论了MP3以及盗版音乐的关系,其中引用了一位业内人士的话表示:“主流唱片公司很少关心互联网上的发展,他们的思维就是‘Inside the box’”。
2)"Out of the box"(开箱即用)也用作"off the shelf"(现货供应)的同义词,其含义是指能够满足一定需求的、已经作好了的软件、硬件或两者的结合形式。如不采用,就需要投入专门的人力物力来开发。
例句:
The Common Annotations for the Java Platform' were introduced with Java EE version 5 and are also included out-of-the-box beginning with Java SE version 6.