3 ms·
> 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
by crypto5 13y ago
> 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);
long count = 0;
for(Future<Long> f: futures) count += f.get();