I am trying to get a better understanding of how static methods (common in util classes) and Singleton classes work in web applications. I understand that a Singleton class would only have one instance per jvm similarly with static methods, but how do these not become a bottleneck in web applications - as the way I am( maybe erroneously) thinking about it is for every client accessing they are bottlenecking on these static methods - I guess also I don't understand how the application server (JBoss in my case) handles threading and the like(when load becomes heavy for instance). Know what I mean? Any articles etc. explaining these concepts would be much appreciated? Thanks
While there is only one copy of the object (singleton) or method (static), there isn't a lock. This means that multiple callers can be in the object/method at the same time. For more on this search for the word "threadsafe". That word will show you objects that allow multiple callers at the same time. (along with those that don't handle it properly at all.)
If you were using the synchronized keyword, you would have a bottleneck as then only one thread/caller could access at a time.