Singleton and performance

Hi: I have a multi-threaded Java program. There are many loners. I am wondering if singleton will reduce the performance of a multi-threaded program, especially bandwidth. Some Singletons are just one object, some singletons are concurrentHashmap and / or atomicinteger.

+3
source share
3 answers

If your singletones are unchanged, they will not lead to a decrease in performance.

However, as you said, if your code has parallel ( synchronized) data structure syntaxes, then your performance will decrease compared to non-competitive data structures.

, , , . , , , .

, , , , .

+8

, , , . , . , . , ; n , , n .

, , . , , , . , .

, (, ), .

+2

, , , . , Java-.

0

All Articles