groovy - Is there a way to run delayed or scheduled task with GPars? -
i'm building concurrent application on top of gpars library. contains thread pool under hood, solve concurrency-related tasks means of pool.
i need run task delay (e.g. 30 seconds). want run tasks periodically.
are there ways implements these things gpars?
what thread.sleep
delaying , quartz scheduling? know there obvious choices don't see wrong using them.
what mean mix gpars bit of higher order closures e.g.:
@grab(group='org.codehaus.gpars', module='gpars', version='1.2.1') def delaydecorator = {closure, delay -> return {params -> thread.sleep (delay) closure.call (params) } } groovyx.gpars.gparspool.withpool() { def closures = [{println it},{println + 1}], delay = 1000 closures.collect(delaydecorator.rcurry(delay)).eachparallel {it (1)} }
Comments
Post a Comment