Java – Using Static Methods in Web Context

javajvmweb-applications

What happens when concurrent requests call the same static Java method running on an application server?

Say that a method run takes 2 seconds and receives 100 calls in a given second. The method itself wouldn't read/write outer state.

Could it be better to let it be an instance method instead?

Best Answer

If the method does not access/change any external state, it is in fact a function. There's nothing wrong with that (some programming languages are based entirely on functions), and it will not cause any performance problems (at least not due to being static).