Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A {
- int a;
- int b;
- public A() {
- a = 1;
- b = 2;
- }
- public int getA() {return a;}
- public int getB() {return b;}
- }
- class Factory {
- private A a;
- public A getA() {
- if (a == null) {
- synchronized(this) {
- if (a == null) {
- a = new A();
- }
- }
- }
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement