Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public class BugSimulate {
  2.  
  3. static {
  4. init();
  5. }
  6.  
  7. private static void init() {
  8. Map<Integer, String> map = new HashMap<>();
  9.  
  10. int i = 0;
  11. map.put(++i, "1");
  12. map.put(++i, "1");
  13. map.put(++i, "1");
  14. map.put(++i, "1");
  15. map.put(++i, "1");
  16. map.put(++i, "1");
  17. map.put(++i, "1");
  18. map.put(++i, "1");
  19. map.put(++i, "1");
  20.  
  21. // stuck
  22. map.keySet().parallelStream().forEach(e -> {
  23. System.out.println(e);
  24. });
  25.  
  26. // no stuck
  27. // map.keySet().parallelStream().forEach(System.out::println);
  28. }
  29.  
  30. @Test
  31. public void test() {
  32. new BugSimulate();
  33. }
  34. }
  35.  
  36. e -> {System.out.println(e);}
  37.  
  38. System.out::println
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement