use of org.apache.commons.collections.map.HashedMap in project Gargoyle by callakrsos.
the class CachedMapTest method miltiThread.
@Test
public void miltiThread() throws InterruptedException {
for (int i = 0; i < 10; i++) {
final int inn = i;
Thread thread = new Thread(() -> {
String name = Thread.currentThread().getName();
CachedMap<Object, Object> cachedMap = new CachedMap<>(1000);
cachedMap.put("sample", "zz" + inn);
cachedMap.put("sample22", "zz" + inn);
System.out.println(name + " " + cachedMap.get("sample"));
try {
Thread.sleep(1500);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println(name + " " + cachedMap.get("sample"));
System.out.println(name + " " + cachedMap.get("sample22"));
HashedMap hashedMap = new HashedMap();
hashedMap.put("sample", "zz" + inn);
hashedMap.put("sample22", "zz" + inn);
cachedMap.putAll(hashedMap);
System.out.println(name + " " + cachedMap);
try {
Thread.sleep(1500);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(name + " " + cachedMap);
}, "Name" + i);
thread.start();
}
Thread.currentThread().sleep(5000);
}
use of org.apache.commons.collections.map.HashedMap in project Gargoyle by callakrsos.
the class CachedMapTest method simple.
@Test
public void simple() throws InterruptedException {
CachedMap<Object, Object> cachedMap = new CachedMap<>(1000);
cachedMap.put("sample", "zz");
cachedMap.put("sample22", "zz");
System.out.println(cachedMap.get("sample"));
Thread.sleep(1500);
System.out.println(cachedMap.get("sample"));
System.out.println(cachedMap.get("sample22"));
HashedMap hashedMap = new HashedMap();
hashedMap.put("sample", "zz");
hashedMap.put("sample22", "zz");
cachedMap.putAll(hashedMap);
System.out.println(cachedMap);
Thread.sleep(1500);
System.out.println(cachedMap);
}
Aggregations