I had asked a question earlier regarding ExecutorService and Apache Velocity initialization. To give a quick recap -- I have a Java EE frontend which accepts user requests and
your code is not thread-safe since you are sharing config
and template
across all thread instances (and continuously re-setting them). the easiest way to make it thread safe would be to make config
and template
local variables in the method instead of static members. as @JBNizet pointed out in the comments, you have a similar problem in mailBuilder
with a
and b
. you might want to first check out some tutorials on object oriented programming fundamentals and then circle back to this issue (hint, in general you should avoid static member variables except for constants).