On Aug 5, 2008, at 5:23 AM, Karan Malhi wrote:

Question:- What would be the use-case to call an asynchronous method and
expect synchronous behavior?

Not *an* asynchronous method (singular) but *multiple* asynchronous methods (plural). Do methods A, B, and C in parallel and wait for them to complete before continuing. The asynchronous methods could each be doing a web service call, for example, that gather data needed to start the real work.

It's essentially what you could do on your own with a CountDownLatch but cannot do reliably as you are not in control of the threads or even the method execution. Passing a CountDownLatch as a parameter to the asynchronous methods you call and having the methods themselves call latch.countDown() isn't going to work as the container can throw exceptions before and after a bean method call. You have no easy way of knowing if the bean method called countDown().

-David

Reply via email to