我有一个问题单例模式和线程。实现是这样的。
public class Singleton {
private static final Singleton instance = new Singleton();
private SomeClass someField;
// and another private fields
private Singleton() {
someField = new SomeClass(some args);
// init another private fields
}
public Singleton getInstance() {
return instance;
}
public void operation() {
//some operations
someField.method();
}
}
(对不起,我不能提供真实的例子。)接下来的问题是:方法 operation() 线程安全吗?