title: Is there a way to synchronize on String variable in java apart from using intern method
body: <p>Intern method will keep adding the strings into the pool which is a bad idea for long term process.Exact scenario is like this :</p>
  
  <pre><code>// rowKey variable defined below is the value of a row key extracted from a 
  // table of the db. There can be many rowKey values. (&gt;100000).
  String rowKey = "rowId_123123"; 
  /* Once rowKey is extracted, then if another thread extracts the same 
     row from the table, then it should be put to wait. Object locking will
     put all the threads to wait irrespective of the rowKey value which will 
     hinder performance. Interning the string will put it into the pool till 
     jvm execution.
  */ 
  </code></pre>
  
  <p>Is there a way to achieve this without interning the string and <code>synchronizing</code> only on the string. Or if there is a way to convert a string into an object which can be visible to all the threads?</p>