• 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

JavaMail and multi-threading

 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand from the JavaDocs that a javax.mail.Session object is 'thread safe'. I believe this to be true because it says :
A single default session can be shared by multiple applications on the desktop

However, this doesn't imply that it's necessarily performant to share the session, unless I mis-comprehend something about how mail servers work?

If I had 5 threads, all trying to send javax.mail.Messages through the one Session, would they all pile up in serial fashion? Or can the one Session send messages in parallel?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks to me like the Session is just a repository for various properties and defaults. It doesn't actively send messages, it is simply read by the actual mail sending method. Therefore there is no "pile up".
Bill
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah. which tends to 'jive' with another aspect of javamail. There is no such method as "Session.send(Message m)" or "Message.send()". There's only the static "Transport.send(Message m)".

So it appears that any time I issue a Transport.send, that it will reconnect with the mail server, as specified in the Session. No persistent connection *ought* to be inferred from the name of this object.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic