import java from java.util.concurrent.TimeUnit import * class Poller(java.lang.Runnable): def run(self): values = [java.lang.System.currentTimeMillis().toString()] print ",".join(values) class Stopper(java.lang.Runnable): def run(self): pollerHandle.cancel(1) stopperHandle.cancel(1) scheduler.shutdown() scheduler = java.util.concurrent.Executors.newScheduledThreadPool(1) pollerHandle = scheduler.scheduleAtFixedRate(Poller(), 0, 5, SECONDS) stopperHandle = scheduler.schedule(Stopper(), 60, SECONDS)