title: java multithreading method that can acess atmost 3 threads concurrently
body: <p>Hi today in interview they asked a multi threading question that create a procedure in which there is a method getDBConnect() so that atmost 3 threads can access it concurrently. if 4th thraed try to access getDBConnect() method then 4th thread will go on wait state if anyone of 3 thread release the method getDBConnect() then 4th thread will access the getDBConnect() method using simple thread or executor thread.</p>
  
  <p>Please help me to understand how can i make program of multi threading so that above criteria should be satisfied.</p>