Object Pooling in Java

后端 未结 7 1665
鱼传尺愫
鱼传尺愫 2020-12-29 08:19

What are the pro\'s and con\'s of maintaining a pool of frequently used objects and grab one from the pool instead of creating a new one. Something like string interning exc

7条回答
  •  生来不讨喜
    2020-12-29 08:31

    Object pools are generally only a good idea for expensive object like database connections. Up to Java 1.4.2, object pools could improve performance but as of Java 5.0 object pools where more likely to harm performance than help and often object pools were removed to improve performances (and simplicity)

提交回复
热议问题