title: String immutability and wait method in synchronized block
body: <p>I am new to Java and while I was reading through Java language I got into two doubts. Though I referred many websites and but still I am not very clear.</p>
  <ol>
  <li><p>Why string class is immutable ? I saw some examples with <code>new File(str)</code> which leads to security threat, but I don't understand how if string is immutable, it will help this scenario.</p>
  </li>
  <li><p>Another doubt is why wait, notify and notifyall should be inside synchronized block. I know if not it throws <code>illegalMonitorException</code>. But I want to know the technical background why it should be in synchronized block and why not without in synchronized block wait and notify can have same behavior.</p>
  </li>
  </ol>