Different between immutable and effectively immutable objects?

后端 未结 4 923
粉色の甜心
粉色の甜心 2021-02-04 02:23

This is a sentence from Java Concurrency in Practice

Shared read-only objects include immutable and effectively immutable objects.

4条回答
  •  长情又很酷
    2021-02-04 02:50

    Take a look at this answer:

    effectively immutable and immutable The difference between effectively immutable and immutable is that in the first case you still need to publish the objects in a safe way. For the truly immutable objects that isn't needed. So truly immutable objects are preferred because they are easier to publish, the reasons I stated above say why you might prefer unsynchronized publication.

    https://stackoverflow.com/a/7887675/1007546

提交回复
热议问题