Guest User

Untitled

a guest
Apr 5th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. public static void main(String[] args) {
  2.  
  3. List<String> emails = Lists.newArrayList();
  4. emails.add("first-person@gmail.com");
  5. emails.add("second-person@gmail.com");
  6. emails.add("third-person@gmail.com");
  7. emails.add("fourth-person@gmail.com");
  8. emails.add("fifth-person@gmail.com");
  9. emails.add("sixth-person@gmail.com");
  10. emails.add("seventh-person@gmail.com");
  11. emails.add("eighth-person@gmail.com");
  12. :
  13. :
  14.  
  15. for(String email: emails) {
  16. sendMail(email);
  17. }
  18. }
  19. private static void sendMail(final String email) {
  20. // function will call many other services for getting the information required for sending the email
  21. try {
  22. Thread.sleep(10000);
  23. System.out.println("ownerEmailDetail====>"+email);
  24. } catch (InterruptedException e) {
  25. e.printStackTrace();
  26. }
  27. }
  28.  
  29. public static void main(String[] args) {
  30.  
  31. List<String> emails = Lists.newArrayList();
  32. emails.add("first-person@gmail.com");
  33. emails.add("second-person@gmail.com");
  34. emails.add("third-person@gmail.com");
  35. emails.add("fourth-person@gmail.com");
  36. emails.add("fifth-person@gmail.com");
  37. emails.add("sixth-person@gmail.com");
  38. emails.add("seventh-person@gmail.com");
  39. emails.add("eighth-person@gmail.com");
  40. :
  41. :
  42.  
  43. emails.stream().parallel().forEach(email -> {
  44. System.out.println("given==>"+email);
  45. sendMail(email);
  46. });
  47. }
  48. private static void sendMail(final String email) {
  49. // function will call many other services for getting the information required for sending the email
  50. try {
  51. Thread.sleep(10000);
  52. System.out.println("ownerEmailDetail====>"+email);
  53. } catch (InterruptedException e) {
  54. e.printStackTrace();
  55. }
  56. }
Add Comment
Please, Sign In to add comment