title: How can JAVA give two lock to the same code segment?
body: <p>I have two locks -- lock1 and lock2 in my code, and I want to give one code segment these two lock as follows:</p>
  
  <pre><code>synchronized(lock1 || lock2) {
      // code
  }
  </code></pre>
  
  <p>This means that if lock1 or lock2 is busy, this code segment will wait until both locks free. How can I do this? Thank you.</p>