Created
May 31, 2011 15:21
-
-
Save nobeans/1000681 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def worker = { latch, num -> | |
println "ready: $num" | |
latch.countDown() | |
latch.await() | |
Thread.sleep(num * 10) | |
println num | |
} | |
def latch = new java.util.concurrent.CountDownLatch(args.size()) | |
args.each { | |
Thread.start worker.curry(latch, it as int) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def latch = new java.util.concurrent.CountDownLatch(args.size()) | |
groovyx.gpars.GParsPool.withPool(args.size() ?: 1) { | |
args.eachParallel { | |
println "ready: $it" | |
latch.countDown() | |
latch.await() | |
Thread.sleep((it as int) * 10) | |
println it | |
} | |
} |
Author
nobeans
commented
May 31, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment