For those who have wondered how to implement Neal Gafter's example 'for eachConcurrently' API with BGGA Closures, here's one attempt:ForEachConcurrently.java
There's a bonus 'for eachEntryConcurrently' in there as well.
I'm sure it can be improved (suggestions welcome) and it certainly deserves a decent explanation, which is coming, but I'll make one comment at this point:
Adding support for nonlocal transfers across different threads required two lines of code.
Two lines is easy. I like easy. Especially when threads are involved.
2 comments:
Marc,
nice code, congratulations!
Luc Duponcheel
by the way
completionService.submit({ =>
Throwable result = null;
if (!cancelled) {
try {
task.execute();
}
catch (Throwable ex) {
cancelled = true;
result = ex;
}
}
result
});
works fine for me instead of the
anonymous class
Post a Comment