zjffdu commented on a change in pull request #3523: [ZEPPELIN-4326][spark]Spark 
Interpreter restart failed when no suffic…
URL: https://github.com/apache/zeppelin/pull/3523#discussion_r347918421
 
 

 ##########
 File path: 
zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java
 ##########
 @@ -32,6 +34,7 @@
     implements WrappedInterpreter {
   private Interpreter intp;
   volatile boolean opened = false;
+  private Lock lock = new ReentrantLock();
 
 Review comment:
   hmm, I think one synchronized is enough. 
   It can be changed as 
   
   ```
     public void open() throws InterpreterException {
       if (opened == true) {
         return;
       }
   
       synchronized (intp) {
         if (opened == false) {
           intp.open();
           opened = true;
         }
       }
     }
   ```
   
   Any reason using lock instead ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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