The code is like below
public class UAUtil {
private static String sUA = null;
private static Object sLock = new Object();
public static void clear() {
synchronized (sLock) {
sUA = null;
}
}
public static String getUserAgent() {
synchronized (sLock) {
if (sUA == null) {
Context context = CoreService.getAppContext();
sUA = ...;
}
}
return sUA;
}
So I wonder does it matter to return the sUA within or out of the synchronized block?