We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
我看这个 EXTENSION_INSTANCES 只是用来实例化,那么能不能改成这样? 难道只是因为 putIfAbsent 是原子性的?在进入方法之前,不也用 synchronized 加锁了?
private T createExtension(String name) { // 从加载类缓存中获取 class 对象 Class<?> clazz = getExtensionClasses().get(name); if (clazz == null) { throw new RuntimeException("No such extension of name " + name); } T instance = null; try { instance = (T) clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { log.error(e.getMessage()); } return instance; }
The text was updated successfully, but these errors were encountered:
而且dubbo里面也是这么写,只是多了一个摧毁的操作
Sorry, something went wrong.
我感觉源码里面就是ioc思想,一个类创建一次就好了,可以一直用,你每次用的时候都创建一个新的,效率多低
No branches or pull requests
我看这个 EXTENSION_INSTANCES 只是用来实例化,那么能不能改成这样?
难道只是因为 putIfAbsent 是原子性的?在进入方法之前,不也用 synchronized 加锁了?
The text was updated successfully, but these errors were encountered: