【发布时间】:2013-09-19 12:44:06
【问题描述】:
在this explanation from the JLS中不应该是myS.equals("/usr")吗?
Final 字段旨在提供必要的安全保证。 考虑以下示例。一个线程(我们将其称为 线程 1) 执行
Global.s = "/tmp/usr".substring(4);当另一个线程(线程 2)执行时
String myS = Global.s; if (myS.equals("/tmp"))System.out.println(myS);字符串对象是不可变的,而字符串操作可以 不执行同步。
【问题讨论】: