如何缩小连接 [英] How to shrink the connection

查看:83
本文介绍了如何缩小连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Java类中创建可以
的方法 1)使用后缩小池中的连接,
2)重命名连接名称

How to create a method in java class that can
1)shrinking the connection in pool after use,
2)rename the connection name

推荐答案

池中的空闲连接是未使用的连接.
要从池中删除空闲连接,请使用以下概念/
1.时间连接空闲
2.即使闲置也要保留的最小数量.
3.保留上次使用连接的时间.
4.当前是否正在使用连接.

如果创建一个自己的池,那么他们将创建一个线程/计时器,该线程/计时器在被触发时会检查空闲时间(当前时间减去上次使用的时间),并删除(关闭)空闲时间过长的连接.重复直到达到最小值.

如果一个人正在使用另一个池,则除了查找池的配置外,相同的想法适用.

至于名称",池只能与一个位置关联.跟踪各个连接没有任何意义(尽管int是合适的.)池本身可能有一个名称,但这取决于池的实现.
A idle connection in a pool is a connection that is not being used.
To remove idle connections from a pool the following concepts are used/
1. Time connection is idle
2. A minimum number to keep even if idle.
3. The time that a connection was last used is kept.
4. Whether a connection is currently in use.

If one creates their own pool then they create a thread/timer which when fired checks the idle time (current time minus last time used) and removes (closes) connections that have been idle too long. That is repeated until the minimum is reached.

If one is using another pool then the same idea applies except one looks to the configuration of the pool.

As for the ''name'', a pool should only be associated with a single location. There is no point in keeping track of individual connections (although an int is suitable.) The pool itself might have a name but that is dependent on the implementation of the pool.


这篇关于如何缩小连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆