fingthinking opened a new issue #1634: 
为什么要在AbstractMonitorFactory#getMonitor这个地方要用上锁
URL: https://github.com/apache/incubator-dubbo/issues/1634
 
 
   ```Java
    public Monitor getMonitor(URL url) {
           url = 
url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY,
 MonitorService.class.getName());
           String key = url.toServiceStringWithoutResolving();
           LOCK.lock();
           try {
               Monitor monitor = MONITORS.get(key);
               if (monitor != null) {
                   return monitor;
               }
               monitor = createMonitor(url);
               if (monitor == null) {
                   throw new IllegalStateException("Can not create monitor " + 
url);
               }
               MONITORS.put(key, monitor);
               return monitor;
           } finally {
               // 释放锁
               LOCK.unlock();
           }
       }
   ```
   这段代码中用了LOCK,个人感觉这玩意很重啊,为什么这种方式,难道仅仅是为了每个url只创建一次Monitor?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to