SharedHashMapBuilder builder = new SharedHashMapBuilder();
String shmPath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "SHMTest1";
//Declare as a ConcurrentMap rather than Map if you want to use putIfAbsent()
Map<String, SHMTest1Data> theSharedMap = builder.create(new File(shmPath), String.class, SHMTest1Data.class)
<p class="indent">
SHMTest1Data data = theSharedMap.get("whatever");
if (data == null) {
//From 1.8, we could use putIfAbsent() as that's been added to the Map interface.//Alternatively we can cast to SharedHashMap and use putIfAbsent().//But for this test just bang it in, doesn't matter if something//else gets in first as you'll see below
data = new SHMTest1Data(2);
theSharedMap.put("whatever", data);
}
<p class="indent">