Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. class A {
  2. int a;
  3. int b;
  4.  
  5. public A() {
  6. a = 1;
  7. b = 2;
  8. }
  9.  
  10. public int getA() {return a;}
  11. public int getB() {return b;}
  12. }
  13.  
  14. class Factory {
  15. private A a;
  16. public A getA() {
  17. if (a == null) {
  18. synchronized(this) {
  19. if (a == null) {
  20. a = new A();
  21. }
  22. }
  23. }
  24. return a;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement