import java.util.concurrent.atomic.AtomicInteger import java.util.function.Supplier AtomicInteger atomicInt = new AtomicInteger(1) Supplier supp = { atomicInt.getAndIncrement() } as Supplier 50.times { println supp.get() }