multithreading - java mail using executorservice -


I am using the Java Mail API. I am able to send emails to individual receipts,

  transport.connect (); {Member = list.get (i) message for loop.Set reciprint (mimmessage reciprint.Tip.To, memib + "@ ABC dot com"); Transport.sendMessage (Message, Message .getRecipients (Message. RecipientType.TO)); } Transport.close ();   

The receipt list can be 200,300,500 ... Now I want to implement the executable service in the above case. Can anyone tell me what the approach will be to implement the executable service here?

Using a default performance service is from Execturors (preferably a Single threaded.) Then runable or callable (if you need some feedback) The job that sends mail, takes different parts in the form of parameters (addresses, etc.). Then do the loop exactly as you did in your example, but instead of calling these lines directly, I had already suppressed the task described in each step.
Should you be careful about that the mail server is non thread-safe and if there is only one mail server, then this problem will not solve because you are bound to resources in that case (but the execution is in your main thread Will not be blocked).

Comments