在Java中,是否只读取对字符串的访问需要同步? [英] In Java, does read only access to Strings need to be synchronized?

查看:141
本文介绍了在Java中,是否只读取对字符串的访问需要同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否需要在Java中同步对字符串的只读访问权限?

Is it required to synchronize read only access to Strings in Java?

推荐答案

否。字符串是不可变的。如果你所做的只是读取字符串,那你就没事了。

No. Strings are immutable. If all you're doing is reading the String, you're absolutely fine.

编辑添加:是的,如果你有一个可变的属性,那就改变了该物业需要同步。

Edit to add: Yes, if you have a mutable property, that changing the value of the property would need to be synchronized.

这篇关于在Java中,是否只读取对字符串的访问需要同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆