But I am confused upon how the createMessage() method will be called when the run() is invoked by thread?
The jmsTemplate
will expect a MessageCreator
instance to be passed and it will responsible for calling the MessageCreator's createMessage()
method.
Also somewhere I read there is nothing like "anonymous class" but instead its "anonymous inner class". Why its like that?
Yes. The proper definition is anonymous inner class, since there is no such thing as anonymous public class. While local classes are class declarations, anonymous classes are expressions, which means that you define the class in another expression and so they are called inner.
More info: