Is there an alternate/better way to do this simple logic in java?
<p>I have a method, say method1(), that takes a while to run. During it's execution, if there is another call to method1(), it should be ignored. I have, roughly, something like this</p>

<pre><code>    boolean mFlag = false;

    void method1()
    {
        if(!mFlag)
        {
           mFlag=true;

           // do Stuff

          mFlag=false;
        }
    }
</code></pre>

<p>This works. But I was wondering if there is a better way to do this preferably not involving any flags.</p>
