How to implement wait in a method for another method to be get over in java?
<p>I have a set of methods say <code>m1</code>,<code>m2</code>,<code>m3</code>,<code>m4</code>. Each one need to wait for previous method to finish. If I call <code>m3</code>, it must wait for <code>m2</code>. I thought of using flag for each method, if finished mark it. but for notifying, if <code>m1</code> says <code>notify()</code>, I want this notify only for <code>m2</code>, not for other waiting methods.</p>

<p>I have a component <code>A</code>, which has <code>m1</code>,<code>m2</code>,<code>m3</code> as input methods and <code>m4</code> as output method. Once <code>m3</code> happens it will call <code>m4</code> to produce output. But <code>m1</code>,<code>m2</code>,<code>m3</code> has to be executed in sequence and can be called from different classes. Waiting and corresponding signal must be there.</p>

<p>How can I go about implementing this?</p>
