title: Synchronization between a method and a set of methods
body: <p>I have an object called FooBar which exposes N number of Foo methods and a close method. Foo methods fetches some data and Close disposes the object(which essentially aborts all the Foo methods if they are running). Foo methods can run in parallel(multi-threaded support).</p>
  
  <p>I want Close to work only after all the Foo methods are done. For this, I've added a lock object in all the Foo and Close methods. This way I ensure Close doesn't succeed if Foo operation is going on.</p>
  
  <p>With the above synchronization design, I lose the ability to run Foo methods in parallel.</p>
  
  <p>Is there any design pattern/way to solve the above problem?</p>