Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaMail and multi-threading  RSS feed

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • 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?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • 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
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!