diff --git a/jetcache-core/src/main/java/com/alicp/jetcache/support/JetCacheExecutor.java b/jetcache-core/src/main/java/com/alicp/jetcache/support/JetCacheExecutor.java index 692bf3340..1187ba84f 100644 --- a/jetcache-core/src/main/java/com/alicp/jetcache/support/JetCacheExecutor.java +++ b/jetcache-core/src/main/java/com/alicp/jetcache/support/JetCacheExecutor.java @@ -4,6 +4,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.atomic.AtomicInteger; /** * Created on 2017/5/3. @@ -14,7 +15,7 @@ public class JetCacheExecutor { protected volatile static ScheduledExecutorService defaultExecutor; protected volatile static ScheduledExecutorService heavyIOExecutor; - private static int threadCount; + private static AtomicInteger threadCount = new AtomicInteger(0); static { Runtime.getRuntime().addShutdownHook(new Thread() { @@ -55,7 +56,7 @@ public static ScheduledExecutorService heavyIOExecutor() { synchronized (JetCacheExecutor.class) { if (heavyIOExecutor == null) { ThreadFactory tf = r -> { - Thread t = new Thread(r, "JetCacheHeavyIOExecutor" + threadCount++); + Thread t = new Thread(r, "JetCacheHeavyIOExecutor" + threadCount.getAndIncrement()); t.setDaemon(true); return t; }; diff --git a/jetcache-test/src/main/java/com/alicp/jetcache/test/external/AbstractExternalCacheTest.java b/jetcache-test/src/main/java/com/alicp/jetcache/test/external/AbstractExternalCacheTest.java index b3e827442..05ede3b3a 100644 --- a/jetcache-test/src/main/java/com/alicp/jetcache/test/external/AbstractExternalCacheTest.java +++ b/jetcache-test/src/main/java/com/alicp/jetcache/test/external/AbstractExternalCacheTest.java @@ -38,7 +38,7 @@ protected void nullKeyConvertorTest() { d2.setName("HL2"); cache.put(d1, "V2"); - Assert.assertNull("V2", cache.get(d2)); + Assert.assertNull(cache.get(d2)); Assert.assertNull(cache.get(d3)); } }