@@ -0,0 +1,1562 @@
+package org.onetwo.common.jfishdbm.utils;%0A%0Aimport java.util.concurrent.atomic.AtomicInteger;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport com.google.common.cache.Cache;%0Aimport com.google.common.cache.CacheBuilder;%0A%0Apublic class GuavaThreadsafeTest %7B%0A%09%0A%09@Test%0A%09public void testLocalCache() throws Exception%7B%0A%09%09AtomicInteger count = new AtomicInteger(0);%0A%09%09final Cache%3CString, String%3E caches = CacheBuilder.newBuilder().build();%0A%09%09%0A%09%09Thread t1 = new Thread(()-%3E%7B%0A%09%09%09try %7B%0A%09%09%09%09System.out.println(%22run thread:%22 + Thread.currentThread().getName());%0A%09%09%09%09String res = caches.get(%22test%22, ()-%3E%7B%0A%09%09%09%09%09count.incrementAndGet();%0A%09%09%09%09%09System.out.println(%22cache thread:%22 + Thread.currentThread().getName());%0A%09%09%09%09%09Thread.sleep(1000);%0A%09%09%09%09%09return %22testvalue%22;%0A%09%09%09%09%7D);%0A%09%09%09%09System.out.println(res+%22 thread:%22 + Thread.currentThread().getName());%0A%0A%09%09%09%09Assert.assertEquals(%22testvalue%22, res);%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09t1.start();%0A%09%09%0A%0A%09%09Thread t2 = new Thread(()-%3E%7B%0A%09%09%09try %7B%0A%09%09%09%09System.out.println(%22run thread:%22 + Thread.currentThread().getName());%0A//%09%09%09%09Thread.sleep(500);%0A%09%09%09%09String res = caches.get(%22test%22, ()-%3E%7B%0A%09%09%09%09%09count.incrementAndGet();%0A%09%09%09%09%09System.out.println(%22cache thread:%22 + Thread.currentThread().getName());%0A%09%09%09%09%09return %22testvalue2%22;%0A%09%09%09%09%7D);%0A%09%09%09%09System.out.println(res+%22 thread:%22 + Thread.currentThread().getName());%0A%09%09%09%09%0A%09%09%09%09Assert.assertEquals(%22testvalue%22, res);%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09t2.start();%0A%09%09%0A%09%09t1.join();%0A%09%09t2.join();%0A%0A%09%09Assert.assertEquals(1, count.get());%0A%09%7D%0A%09%0A%0A%7D%0A

add guava threadsafe test