TimerTask
Timer
public class RefreshConnStateTask extends TimerTask {    /**
     * DBConnectionPool instance
     */
    private DBConnectionPool _connectionPool = null;    /**
     * write trace
     */
//    private Log _log = null;    /**
     * constructor
     */
    public RefreshConnStateTask() {
        this._connectionPool = DBConnectionPool.getInstance();
//        _log = this._connectionPool.getLog();
    }    /**
     * refresh connection state
     */
    public void run() {
        synchronized(this._connectionPool.getLock()) {
            Vector statVec = this._connectionPool.getUsedConnVec();
            long lIncreasement = this._connectionPool.getTimerPeriod();
            ConnectionState connStat = null;
            Connection conn = null;
            long lInterval = 0;            // refresh each connection state in _usedConnVec
            for(int i = 0; i < statVec.size(); i++){
                connStat = (ConnectionState)statVec.get(i);
                connStat.incInterval(lIncreasement);                // release connection which is overtime
                lInterval = connStat.getInterval();
                if(lInterval >= this._connectionPool.getConnTimeLimit()) {
                    conn = connStat.getConnection();
                    this._connectionPool.releaseConnection(conn);
                }
            }
        }
    }
}    public void startTimer(){
        // start refresh connection state timer
        this._refConnStatTask = new RefreshConnStateTask();
        this._refConnStatTimer = new Timer();
        this._refConnStatTimer.schedule(this._refConnStatTask,
                                       this._timerPeriod,
                                       this._timerPeriod);
       Log.logInformation("Connection status refresh timer started successfully.");
    }定时刷新查看连接时间