views:

543

answers:

1

The method is static, but I cannot find mention of if it is thread-safe or not. I plan on hitting this method with several threads at once and I would like to avoid a synchronized block if possible.

javax.mail.Transport.send(msg);
+1  A: 

It is usually bad design and a violation of expectations to have a static method that is not thread-safe.

The documentation indeed appears to be devoid of any mention of thread-safety, but a quick glance through the code suggests that the implementation is thread-safe by creating a thread-confined Transport instance on every call and delegating to that.

To be absolutely sure I recommend pulling a couple of days out the calendar for a proper analysis.

Christian Vest Hansen