Skip to content

Instantly share code, notes, and snippets.

@thobson
Last active November 24, 2017 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thobson/6272ac29c0da1f617493 to your computer and use it in GitHub Desktop.
Save thobson/6272ac29c0da1f617493 to your computer and use it in GitHub Desktop.
public class SingleStreamTest {
public static void main(String args[]) throws Exception {
SingleStreamTest test = new SingleStreamTest();
test.executeTasks();
}
void executeTasks() throws Exception {
final List<Integer> firstRange = buildIntRange();
firstRange.parallelStream().forEach((number) -> {
try {
// do something slow
Thread.sleep(5);
} catch (InterruptedException e) { }
});
}
private List<Integer> buildIntRange() {
List<Integer> numbers = new ArrayList<>(5);
for (int i=0; i<6000; i++)
numbers.add(i);
return Collections.unmodifiableList(numbers);
}
}
@SijiaLiu
Copy link

hello guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment