title: In Scala, does synchronized block lock all the global variables accessed in the block?
body: <pre><code>import scala.collection.immutable.HashMap
  
  class MyClass {
      var globalOne = HashMap[String, String]()
      var globalTwo = HashMap[String, String]()
  
      def dosync(k:String, v:String) = {
          synchronized {
              globalOne = globalOne.updated(k, v)
              globalTwo = globalTwo.updated(k, v)
          }
      }
      def getKey(k:String) = {
          globalOne.get(k)
      }
  }
  </code></pre>
  
  <p>Is "getKey" blocked when "dosync" is getting executed because dosync is accessing the global variables which getKey is accessing too?</p>