Passing lambda to a Timer instead of TimerTask
<p>I want to perform a delayed operation on a map, so I am using <code>Timer</code>, to which I am passing a <code>TimerTask</code> and a delay in milliseconds:</p>

<pre><code>timer.schedule(new TimerTask() {
    public void run() {
        tournaments.remove(id);
    }
}, delay);
</code></pre>

<p>This is some sort of primitive cache-like functionality where I set an expiration time on a new resource that was just created.</p>

<p>I thought I could do that using lambdas, just like follows:</p>

<pre><code>times.schedule(() -&gt; tournaments.remove(id), delay);
</code></pre>

<p>But the compiler says this cannot be done. Why? What am I doing wrong? Could I use lambdas to achieve more concise code or it's simply not possible here and I should stick to an anonymous class?</p>