1

There are several getXXXCount method defined in the BaseGenericObjectPool class

  1. BaseGenericObjectPool.getBorrowedCount

  2. BaseGenericObjectPool.getCreatedCount

  3. BaseGenericObjectPool.getDestroyedCount

But all of them are computed since the pool was created, that is, the count is accumulated.

I would ask how to figure out the number of being borrowed objects and being idle objects the moment when user asks for these count.

Tom
  • 5,848
  • 12
  • 44
  • 104

1 Answers1

0

BaseGenericObjectPool abstract class declares getNumIdle() method, which returns "the number of instances currently idle in the pool". BaseGenericObjectPool by itself does not provide the number of borrowed instances.

To have the number of borrowed instances you should look at classes, which implement ObjectPool or KeyedObjectPool interfaces, for example GenericObjectPool or GenericKeyedObjectPool class. These interfaces both declares the getNumActive() method, which returns "the number of instances currently borrowed from this pool" (ObjectPool case) or "the total number of instances current borrowed from this pool but not yet returned" (KeyedObjectPool case).

Alexander Ziubin
  • 35
  • 1
  • 2
  • 7