Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending multiple mails through threads

 
Jaydeep Deshmukh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In our current application, the emails are being sent out to the relevant users in a procedural manner...one after another.

Now this needs to be changed to doing it using threads. I have two questions here.
1. Would this be as straight forward as spawning a thread per email to be sent? Would there be any exceptional scenarios?
2. What if any of the mails fail to go out and throw and exception. How do I keep tabs as to from which thread this exception occured?

Thanks in advance
Jaydeep
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the kind of thing that would make use of an ExecutorService. You probably don't to waste resources creating a new thread for every single mail to be sent. By using an ExecutorService or a similar construct you can put the burden of creating and managing threads on another object and instead pass it a Runnable or Callable and get a Future back if you need to know the result.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic