Skip to content

Instantly share code, notes, and snippets.

@jnizet
Created August 17, 2019 12:28
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 jnizet/d45d2e3754a30c7c364410669ce40e8e to your computer and use it in GitHub Desktop.
Save jnizet/d45d2e3754a30c7c364410669ce40e8e to your computer and use it in GitHub Desktop.
import java.util.Arrays;
import java.util.stream.Collectors;
public class Benchmark {
public static void main(String[] args) {
System.out.println(Arrays.asList(1, 2, 3, 4, 5)
.stream()
.filter(i -> i > 10)
.map(i -> {
try {
Thread.sleep(10000L); // simulating hard work
return i;
}
catch (InterruptedException e) {
return 0;
}
})
.collect(Collectors.toList()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment