Code example for ConcurrentMap

Methods: getputIfAbsent

0
    public static ClassCache getInstance() { 
        return INSTANCE;
    } 
 
    public Class<?> getOrLoadClass(String className) {
        Class<?> clazz = cache.get(className);
        if (clazz == null) {
            try { 
                clazz = Class.forName(className);
                cache.putIfAbsent(className, clazz);
            } catch (ClassNotFoundException cnfe) {
                throw new RuntimeException(cnfe);
            } 
        } 
        return clazz;
    } 
 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE