I am having servlet in user based web-application on tomcat java. I have a servlet Action class says A. I have also created a custom class says B which have some methods.
My question is : Should i create Staitc method in my custom class or can i call them by instantiating the class . I have explained both scenerio below:
Scenerio First:
Servlet A{
B.methodB() // static method.
}
Scenerio Second:
Servlet A{
B b = new B();
b.methodB() // instance method.
}
Will the scenario first be thread safe in my case ? Does static method always need to be synchronized in user based application ?