Last active
November 24, 2017 07:55
-
-
Save thobson/6272ac29c0da1f617493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello guys!