I am writing code like this:
public static void function7() {
String str = "123";
String str2 = "123";
synchronized (str) {
if(str != null) {
str2 = "123";
}else{
str = "456";
}
System.out.println(str2);
}
}
The code compiles well. But the Eclipse plugin, Find bugs, gives the following error report:
Constant strings are interned and distributed among all other classes loaded by the JVM. Thus, it can block what other code can also block. This can lead to very strange and difficult to diagnose blocking and deadlock situations.
What exactly does this mean?
source
share