Java tutorial
import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; public class Main implements Runnable { public void run() { System.out.println("produces " + idSequence.incrementAndGet()); } public static void main(String[] args) { for (int i = 0; i < 200; i++) Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(new Main(), 1, 10, TimeUnit.SECONDS); } private static final AtomicLong idSequence = new AtomicLong(0); }