java-- by GenericObjectPool acquired resources, call the close () method will close or returnObject?

Closing an elegant way is to use the resources try () {} cache () {}

like this:

 

 At this time, try () inside the resource is automatically called after the return statement is executed close () method, then the question is, when we use the connection pool, do not want resources to be close, but to the resource is exhausted Auto returnObject (), then this statement is not elegant try not to use it?

It can be oh ~

 

 

 

 

 

 As can be seen from the above, in fact, go into the pool of connection with an additional layer of the package, connected by actually creating dynamic proxy mode, and the connection of these close () method is redefined, the method calls the close when actually called the returnObject () method ~

Guess you like

Origin www.cnblogs.com/gaoquanquan/p/11593333.html