I recently stumbled upon piece of code similar to the one below. This code does reek right off. Looks like singleton but its not because there is no private constructor. I know for sure this is going to have thread safety issue given big enough load to it. Specially given class instance. Can someone please point out thread safety issues with this code?
public class AClass extends AnotherClass {
public static final AClass instance = new AClass();
public static SomeObject doSomethingThatCallsAService(Params params) {
return methodThatCallsService(params, instance);
}
public static SomeObject methodThatCallsService(Params params, AClass instance) {
-----call service here ---------
instance.doSomethingElse();
}
private void doSomethingElse() {
--- do some trivial work -----
}
}