Holger,

> I cannot see how a blocking borrow(key)
can ever continue when another thread tries to returnObject(key, object)
borrowObject() calls Object.wait() which allows other threads access to 
the locked object (as opposed to Thread.sleep() which would not). 
returnObject() calls notifyAll() which will (when returnObject() exits) 
wake up the borrowing thread.  Hence, WHEN_EXHAUSTED_BLOCK only blocks the 
current thread from continuing execution, it does not stop others from 
returning objects or using other key pools.

Although the wait/notify *could* be made more granular than the current 
top-level implementation, this would only be a performance issue - the 
current model will not block any other threads which can legitimately use 
the GKOP.

Marc




"Holger Hoffstaette" <[EMAIL PROTECTED]> 
Sent by: news <[EMAIL PROTECTED]>
28/10/2006 15:49
Please respond to
"Jakarta Commons Users List" <[email protected]>


To
[email protected]
cc

Subject
[pool] GenericKeyedObjectPool, WHEN_EXHAUSTED_BLOCK & multiple threads







I'm having a bit of a problem understanding a scenario for
GenericKeyedObjectPool. I need to WHEN_EXHAUSTED_BLOCK with a GKOP that is
used from multiple threads, but I cannot see how a blocking borrow(key)
can ever continue when another thread tries to returnObject(key, object),
as the methods are synchronized on the pool instance and would mutually
exclude each other?

Since I only need to block on a keys queue and not on the whole pool -
assuming I'm within the min/max limits - the only way around this seems to
be something like a ConcurrentKeyedObjectPool that does not synchronize
for the top-level map access but rather only on the second-level queue,
right? I was hoping to avoid that since it greatly complicates matters
regarding the pool's overall resource handling.

thanks,
Holger



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to