title: How to restrict specific number of threads to synchronized block in java
body: <p>I am not able to figure out this question. In a multi threaded environment - exactly 3 threads should be able to execute the synchronized block and rest should wait ? </p>
  
  <p>What I understand is when we use synchronization or monitor one thread will wait until the other thread finishes its execution in side synchronized block or method. To achieve multiple thread  to enter inside synchronized block or method we need to use wait(), notify(), notifyAll() i.e. inter thread communication, where wait() method when called on certain object it will takes its lock and give chances to other waiting threads.</p>
  
  <p>So, I am wondering how to do the above question. I am not sure if I have put my question in right way. If its possible do we need to use java concurrent util package or can it be done in basic(core) thread functionality.</p>