Quantcast
Channel: Singleton methods thread safe - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Singleton methods thread safe

$
0
0

I have a question Singleton pattern and threads. Implementation is like this.

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();    }}

(Sorry I can not provide real example.)The question is next: is method operation() thread safe?


Viewing all articles
Browse latest Browse all 4

Trending Articles