简体   繁体   中英

Purpose of Immutable or Unmodifiable Collections

What are the real benefits of Immutable or Unmodifiable collections, or objects?

As programmers, we try to write code without bugs, such that a user cannot break the system, and that bad actors cannot hack into it. To me, Immutable objects seem to try to prevent programmers from making silly mistakes.

Is there more to it than that?

不可变的类和集合确实有助于避免尝试修改同一对象的多个线程的并发问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM