0

I know what is Object Pooling in Java

I was keen to know if there are any better alternatives which can be used in an distributed environment, or specifically with server sockets and database connection sockets.

Any information or leads would be helpful.

Thanks,
Ivard

Community
  • 1
  • 1
topgun_ivard
  • 8,376
  • 10
  • 38
  • 45

3 Answers3

3

Object pooling in general is not a good idea in Java anymore, as in recent JVM versions object creation (and GC) is extremely cheap and safe (much safer than trying to make an object pool threadsafe in a concurrent environment...).

It is only reasonable in case the specific objects are very costly to create and/or consume lots of resources, such as connection pooling. The thread you linked contains some useful looking suggestions for solutions (however, lacking personal experience, I can't recommend any of these).

Péter Török
  • 114,404
  • 31
  • 268
  • 329
1

A better alternative for a distributed environment could be using an application server like JBoss AS to have your pooling needs handled for you.

I am sure (but lack experience with) that the Spring framework provides similar capabilities.

kostja
  • 60,521
  • 48
  • 179
  • 224
0

In some application server, such as JBoss, uses JCA to control database connection and socket pooling.

卢声远 Shengyuan Lu
  • 31,208
  • 22
  • 85
  • 130