Created
March 6, 2012 23:09
-
-
Save nicholashagen/1989663 to your computer and use it in GitHub Desktop.
Groovy Closure to Callable
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
// anonymously invoke a closure into callable and submit to executor | |
// this fails w/o the explicit (Callable) since it converts it to Runnable | |
def executor = java.util.concurrent.Executors.newFixedThreadPool(5) | |
def future = executor.submit((java.util.concurrent.Callable) { | |
'TEST' | |
}) | |
assert('TEST' == future.get()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can also do