title: When thread syncronization happens in java?
body: <p>Am new to Java Thread , while reading i could see that <strong>same instances</strong> on thread object should wait until the  current thread get finished execution .
  Consider I have  two Objects , one is WebApp</p>
  
  <pre><code>class WebApp{
      private String webappName;
      private boolean isQA = false;
      private String path ;
  
      public WebApp(String name , String  path , boolean isQA){
          this.webappName = name;
          this.path = path;
          this.isQA  = isQA;
      }
  }
  </code></pre>
  
  <p>another one is WebAppProeprty</p>
  
  <pre><code>    class WebAppProperty implements Runnable{
  
      private WebApp webapp; 
      private String propertyFile; 
      private String keyValue;
      public String getKeyValue() {
          return keyValue;
      }
      public void setKeyValue(String keyValue) {
          this.keyValue = keyValue;
      }
      public String getPropertyFile() {
          return propertyFile;
      }
      public void setPropertyFile(String propertyFile) {
          this.propertyFile = propertyFile;
      }
  
      @Override
      public void run(){
          writeToPropertyFile();
      }
      public WebAppProperty(WebApp webapp , String propertyFile ){
          this.webapp  = webapp;
          this.propertyFile = propertyFile;
      }
  
  
      private synchronized  void writeToPropertyFile(){
          try{
              // code for write property into text file. 
          }catch (Exception e) {
  
          }
      }
  
  }
  </code></pre>
  
  <p>so if i create two thread like , will the second object should wait for executing the syncronized method ? or it can execute the method parallel.</p>
  
  <pre><code>        WebApp app1  = new WebApp("webapp1", "staging/folder", false);
          WebAppProperty webappProp1 = new WebAppProperty(app1, "a.proeprties");
          webappProp1.setKeyValue("keyvalue");
  
  
          WebAppProperty webappProp2 = new WebAppProperty(app1, "a.proeprties");
          webappProp2.setKeyValue("keyvalue");
  
          Thread t1 = new Thread(webappProp1);
          t1.start();
          Thread t2 = new Thread(webappProp2);
          t2.start();
  </code></pre>
  
  <p>Note: Updated thread accessing same resource</p>
  
  <p>If two users try to access same resource will the above code block the second user ? if not  please help me with  the correct way  to do it.</p>