• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending multiple mails through threads

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic