Re:Go Concurrency Patterns: Pipelines and cancellation
by crypto5 on Friday March 14, 2014 @02:12AM
(#7397231)
> I think one huge difference is that a channel in Go is a stream of data, in which each element can cause the consuming code to wait for new responses. In your example, the future can only return one bit of data.
In java you also can do something like:
List<Future<Long>> futures = new ArrayList<>();
for(int i = 0; i < n; i ++) futures.add(some parallel execution logic);
In java you also can do something like:
List<Future<Long>> futures = new ArrayList<>();
for(int i = 0; i < n; i ++) futures.add(some parallel execution logic);
long count = 0;
for(Future<Long> f: futures) count += f.get();