Passing lambda to a Timer instead of TimerTask [duplicate]
问题 This question already has answers here : Lambda Expressions for Abstract Classes (3 answers) How to use TimerTask with lambdas? (5 answers) Closed 4 years ago . I want to perform a delayed operation on a map, so I am using Timer , to which I am passing a TimerTask and a delay in milliseconds: timer.schedule(new TimerTask() { public void run() { tournaments.remove(id); } }, delay); This is some sort of primitive cache-like functionality where I set an expiration time on a new resource that was