public static ScheduledExecutorService defaultExecutor()

in jetcache-core/src/main/java/com/alicp/jetcache/support/JetCacheExecutor.java [36:64]


    public static ScheduledExecutorService defaultExecutor() {
        if (defaultExecutor != null) {
            return defaultExecutor;
        }
        reentrantLock.lock();
        try{
            if (defaultExecutor == null) {
                ThreadFactory tf = r -> {
                    Thread t = new Thread(r, "JetCacheDefaultExecutor");
                    t.setDaemon(true);

                    ClassLoader classLoader = JetCacheExecutor.class.getClassLoader();
                    if (classLoader == null) {
                        // This class was loaded by the Bootstrap ClassLoader,
                        // so let's tie the thread's context ClassLoader to the System ClassLoader instead.
                        classLoader = ClassLoader.getSystemClassLoader();
                    }
                    t.setContextClassLoader(classLoader);

                    return t;
                };
                int coreSize = Math.min(4, Runtime.getRuntime().availableProcessors());
                defaultExecutor = new ScheduledThreadPoolExecutor(coreSize, tf);
            }
        }finally {
            reentrantLock.unlock();
        }
        return defaultExecutor;
    }