Is there any way to obtain the convenience and thread - safety benefits of immutability with data that 更改的数据获得不变性的便利和线程安全的长处呢?
They are inherently thread - safe assuming their immutability is ensured through the use of the 它们在本质上就是线程安全的(假设它们的不可变性是通过使用
The java programming language s implementation of immutability isn t tight enough for two reasons Java编程言语中,对于不变性的实现不够严格,有两个原因:
Regular readers of this column will not be surprised to hear me extolling the virtues of immutability 本栏目的普通读者听到我赞美不可变性的优点时不会感到意外。
Classes for representing complex numbers or arbitrary - precision rational numbers would be good candidates for immutability 表示复数或精度任意的有理数的类将比较适合于不变性。
Brian goetz explains some of the benefits of immutability and some guidelines for constructing immutable classes 中, brian goetz说明了不变性的一些长处和构造不变类的一些准则。
Package , is a good example of how to harness the power of immutability while still permitting occasional modifications 类是如何既利用不变性的能力,又仍允许偶尔修改的一个良好示例。
" and others , i extolled the virtues of immutability - immutable objects cannot get into an inconsistent state ” (和其他文章中) ,我赞扬了不可变的优点,不可变对象不能进入不稳定的状态。
The run - time system should take care of any semantics required to guarantee this immutability . a simple copy is often not sufficient 运行时系统应通过相关语义来保证这种不变性(简单的复制通常是不够的) 。