是新來Spring.I有一個Spring bean countService這是一個單方法變量
public class CountService {
private int doCount() {
String commentsText = null;
List tranIds = new ArrayList();
int count = 0;
// ---business logic----
return count;
}
}
是方法變量commentsText,tranIds線程安全的?在此先感謝
取決於你的業務邏輯做什麼。但是,這個代碼是線程安全的,因爲所有的變量都是本地的 –