How can I make a thread wait for more than one lock?

Discussions

Performance and scalability: How can I make a thread wait for more than one lock?

  1. This is a method in MFC,wait for more than one lock,anyone of it notify,the thread go far,do something.
  2. Look at java.util.concurrent package. There is CountdownLatch and CyclicBarrier classes that may help.
  3. is this the right question?[ Go to top ]

    Are you sure you want that? Or is the question you really are asking more to do with if you have a limited resource, and you want to have a fixed set of "locks" over the resource, and threads wait to acquire from a fixed set of leases? Once a lease is released the next waiting thread is notified and acquires the lease. If you're using Java 5, the JDK now provides very constructs you can use for fixed pool lease semantics. If you're not using Java 5 - I recommend Doug Lea's original: http://g.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html