title: how to use string id to Synchronization my block of code
body: <p>I want to use string id to synchronization my code.</p>
  <p>this is what I am trying to implement.</p>
  <pre><code>public void executeSomeCode(Object object)
  {
     String firstString= object.getFirstString();
     String  secondString= object.getSecondString();
     
     Synchronization(firstString)
     {
        Synchronization(secondString)
        {
         //retrieve data from database and execute code here and save back them.
        }
     }
  
  }
  </code></pre>
  <p>but can we use directly string for synchronisation as mention in above diagram.</p>
  <p>I already implemented synchronization using concurrenthashmap as mention in below link and that's working fine.
  <a href="https://stackoverflow.com/a/54672371/11053922">https://stackoverflow.com/a/54672371/11053922</a></p>
  <p>edit :-
  to avoid deadlocks,i will use these String in a lexicographically order.</p>