Thursday, August 28, 2008

for eachConcurrently

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.

5 comments:

Luc Duponcheel said...

Marc,

nice code, congratulations!

Luc Duponcheel

Luc Duponcheel said...

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

Anonymous said...

Erectile Dysfunction Related Links :


Buy Cialis


Harvard

DMTMACHINEELVES said...

make money online
internet tips
work from home
Video Tips
Shopping Tips
Car Tips
Computer Tips
Travel Tips
Finance Tips

三重古天樂 said...

酒店經紀 酒店小姐 酒店經紀公司
台北酒店工作 台北酒店經紀人 酒店兼差 酒店兼職 酒店公關 酒店上班 台北酒店上班 酒店打工 酒店工作內容 酒店pt 台北酒店 便服店 禮服店 酒店 酒店工作 酒店上班時間 酒店上班薪水 酒店上班內容 現領 當日領 酒店經紀 酒店打工 酒店工作 酒店上班 酒店兼差 酒店兼職 打工兼差 打工兼職 台北酒店 酒店應徵 禮服店 酒店 經紀 打工 兼差便服店 台北酒店經紀 酒店薪水 酒店工作內容 酒店時間 酒店經濟 美式餐廳 咖啡廳
打工兼職 打工兼差 酒店營業時間
酒店經濟 酒店面試
2015/08/26