Java - threads + action
<p>I'm new to Java so I have a simple question that I don't know where to start from - 
I need to write a function that accepts an Action, at a multi-threads program , and only the first thread that enter the function do the action, and all the other threads wait for him to finish, and then return from the function without doing anything.</p>

<p>As I said - I don't know where to begin because, 
first -  there isn't a static var at the function (static like as in c / c++ ) so how do I make it that only the first thread would start the action, and the others do nothing ?
second - for the threads to wait, should I use</p>

<pre><code>public synchronized void lala(Action doThis)
{....}
</code></pre>

<p>or should i write something like that inside the function</p>

<pre><code>synchronized (this)
{
...
notify();
}
</code></pre>

<p>Thanks !</p>
