java - Should I use a pool of objects, a singleton or static methods in a multi-threaded environment? -


i have helper class creates objects, builder. helper class not have state. on multi-threaded environment; specifically, web server. class candidate being singleton?

what difference between implementing class singleton , using static methods?

what effect of thousands of users accessing object/these methods be?

i make class regular class, instantiating every time needed waste of memory.

no need use singleton here (since not need state), can use static methods. singleton in principle offers more control allowing state. there won't difference in case, static methods easier implement , use.

  • what effect of thousands of users accessing object/these methods be? again, not difference in both cases, in singleton can have state, , if not implement carefully, code non-thread-safe. every user calling static method gets own "instance" of method (i think ask), no risk of running thread-safety problems there.

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -