假设我有一个Utility类:
public class Utility {
private Utility() {} //Don't worry, just doing this as guarantee.
public static int stringToInt(String s) {
return Integer.parseInt(s);
}
};
现在,假设在一个多线程应用程序中,一个线程调用Utility.stringToInt()
方法,同时,另一个线程调用相同的方法,并传递不同的s
参数。
在这种情况下会发生什么?Java会锁定静态方法吗?