/*
 * Copyright 2015 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public class PutIfAbsentIdiom {
	static Map<String, Date> chm = new ConcurrentHashMap<>();
	
	public static Date putDate(String key) {
		Date date = chm.get(key);
		if (date == null) {
			date = new Date(System.currentTimeMillis());
			chm.put(key, date);
		}
		return date;
	}
	
	public static void main(String[] args) {
		final String key = "myKey";
		Thread t1 = new Thread() {
			public void run() {
				Date date = putDate(key);
				System.out.println(date);
			}
		};
		Thread t2 = new Thread() {
			public void run() {
				Date date = putDate(key);
				System.out.println(date);
			}
		};
		t1.start();
		t2.start();
	}
}

@@ -735,17 +735,18 @@
 Idiom %7B%0A
-%09
+  
 static M
@@ -795,19 +795,19 @@
 ap%3C%3E();%0A
-%09%0A%09
+%0A  
 public s
@@ -839,18 +839,20 @@
  key) %7B%0A
-%09%09
+    
 Date dat
@@ -869,18 +869,20 @@
 t(key);%0A
-%09%09
+    
 if (date
@@ -893,19 +893,22 @@
 null) %7B%0A
-%09%09%09
+      
 date = n
@@ -944,19 +944,22 @@
 lis());%0A
-%09%09%09
+      
 chm.put(
@@ -970,22 +970,26 @@
  date);%0A
-%09%09%7D%0A%09%09
+    %7D%0A    
 return d
@@ -997,14 +997,15 @@
 te;%0A
-%09%7D%0A%09%0A%09
+  %7D%0A%0A  
 publ
@@ -1041,18 +1041,20 @@
 args) %7B%0A
-%09%09
+    
 final St
@@ -1073,18 +1073,20 @@
 myKey%22;%0A
-%09%09
+    
 Thread t
@@ -1096,35 +1096,38 @@
  new Thread() %7B%0A
-%09%09%09
+      
 public void run(
@@ -1122,36 +1122,40 @@
 ic void run() %7B%0A
-%09%09%09%09
+        
 Date date = putD
@@ -1156,36 +1156,40 @@
 = putDate(key);%0A
-%09%09%09%09
+        
 System.out.print
@@ -1198,28 +1198,35 @@
 (date);%0A
-%09%09%09%7D%0A%09%09%7D;%0A%09%09
+      %7D%0A    %7D;%0A    
 Thread t
@@ -1244,19 +1244,22 @@
 ead() %7B%0A
-%09%09%09
+      
 public v
@@ -1270,20 +1270,24 @@
 run() %7B%0A
-%09%09%09%09
+        
 Date dat
@@ -1308,12 +1308,16 @@
 y);%0A
-%09%09%09%09
+        
 Syst
@@ -1342,20 +1342,27 @@
 e);%0A
-%09%09%09%7D%0A%09%09%7D;%0A%09%09
+      %7D%0A    %7D;%0A    
 t1.s
@@ -1373,10 +1373,12 @@
 ();%0A
-%09%09
+    
 t2.s
@@ -1389,9 +1389,10 @@
 ();%0A
-%09
+  
 %7D%0A%7D%0A

Fix indentation errors