Search in sources :

Example 11 with HashedMap

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);
}
Also used : HashedMap(org.apache.commons.collections.map.HashedMap) Test(org.junit.Test)

Example 12 with HashedMap

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);
}
Also used : HashedMap(org.apache.commons.collections.map.HashedMap) Test(org.junit.Test)

Aggregations

HashedMap (org.apache.commons.collections.map.HashedMap)12 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Test (org.junit.Test)6 File (java.io.File)3 ArrayList (java.util.ArrayList)3 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)1 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)1 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)1 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)1 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)1 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)1 CatalogFramework (ddf.catalog.CatalogFramework)1 CreateStorageRequest (ddf.catalog.content.operation.CreateStorageRequest)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 CreateResponse (ddf.catalog.operation.CreateResponse)1 DeleteRequest (ddf.catalog.operation.DeleteRequest)1 DeleteResponse (ddf.catalog.operation.DeleteResponse)1 UpdateResponse (ddf.catalog.operation.UpdateResponse)1 GroovyClassLoader (groovy.lang.GroovyClassLoader)1