Java Transport.send () - is it thread safe?

The method is static, but I cannot find any mention of whether it is thread safe or not. I plan to use this method with multiple threads at the same time, and I would like, if possible, to avoid a synchronized block.

javax.mail.Transport.send(msg); 
+6
java concurrency email
source share
1 answer

As a rule, poor design and violation of expectations have a static method that is not thread safe.

There really is no mention of thread safety in the documentation, but a quick look at the code shows that the implementation is thread safe by creating a Transport instance with a restricted thread on every call and delegating it.

To be absolutely sure, I recommend spending a few days from the calendar for proper analysis.

+5
source share

All Articles