1 package com.puppycrawl.tools.checkstyle; 6 7 11 class InputDoubleCheckedLocking 12 { 13 static Integer one = null; 14 15 private static Integer getOneCorrect() 16 { 17 synchronized (InputDoubleCheckedLocking.class) 18 { 19 if (one == null) 20 { 21 one = new Integer (1); 22 } 23 } 24 return one; 25 } 26 27 private static Integer getOneDCL() 28 { 29 if (one == null) 30 { 31 System.out.println("just to make the AST interesting"); 32 synchronized (InputDoubleCheckedLocking.class) 33 { 34 if (one == null) 35 { 36 one = new Integer (1); 37 } 38 } 39 } 40 return one; 41 } 42 43 private static Integer getSimilarToDCL() 44 { 45 if (one == null) 47 { 48 synchronized (InputDoubleCheckedLocking.class) 49 { 50 if (one == Integer.valueOf(2)) 51 { 52 one = new Integer (1); 53 } 54 } 55 } 56 57 if (one == null) 59 { 60 if (one == null) 61 { 62 one = new Integer (1); 63 } 64 } 65 66 synchronized (InputDoubleCheckedLocking.class) 68 { 69 if (one == null) 70 { 71 one = new Integer (1); 72 } 73 } 74 return one; 75 } 76 77 } 78 | Popular Tags |