@Override
	public void run() {
		int maxNewConnections;

		while (run) {
			maxNewConnections = 0;
			try {
				if (this.lazyInit) { // 无视第一次的信号量
					this.thriftConnectionPartition.getPoolWatchThreadSignalQueue().take();
				}

				maxNewConnections = this.thriftConnectionPartition.getMaxConnections()
						- this.thriftConnectionPartition.getCreatedConnections();

				while (maxNewConnections == 0 || (this.thriftConnectionPartition.getAvailableConnections() * 100
						/ this.thriftConnectionPartition.getMaxConnections() > this.poolAvailabilityThreshold)) {
					if (maxNewConnections == 0) {
						this.thriftConnectionPartition.setUnableToCreateMoreTransactions(true);
					}

					this.thriftConnectionPartition.getPoolWatchThreadSignalQueue().take();
					if (!run) {
						break;
					}
					maxNewConnections = this.thriftConnectionPartition.getMaxConnections()
							- this.thriftConnectionPartition.getCreatedConnections();

				}

				if (maxNewConnections > 0 && !this.thriftConnectionPool.poolShuttingDown) {
					fillConnections(Math.min(maxNewConnections, this.thriftConnectionPartition.getAcquireIncrement()));

					if (this.thriftConnectionPartition.getCreatedConnections() < this.thriftConnectionPartition
							.getMinConnections()) {
						fillConnections(this.thriftConnectionPartition.getMinConnections()
								- this.thriftConnectionPartition.getCreatedConnections());

					}
				}

				if (this.thriftConnectionPool.poolShuttingDown) {
					return;
				}

			} catch (InterruptedException e) {
				// 发生中断事件 停止运行监听器
				if (logger.isDebugEnabled()) {
					logger.debug("Terminating pool watch thread");
				}
				return;
			}
		}
	}
@ Override public void run ( ) { int maxNewConnections ; while ( run ) { maxNewConnections = 0 ; try { if ( this . lazyInit ) { this . thriftConnectionPartition . getPoolWatchThreadSignalQueue ( ) . take ( ) ; } maxNewConnections = this . thriftConnectionPartition . getMaxConnections ( ) - this . thriftConnectionPartition . getCreatedConnections ( ) ; while ( maxNewConnections == 0 || ( this . thriftConnectionPartition . getAvailableConnections ( ) * 100 / this . thriftConnectionPartition . getMaxConnections ( ) > this . poolAvailabilityThreshold ) ) { if ( maxNewConnections == 0 ) { this . thriftConnectionPartition . setUnableToCreateMoreTransactions ( true ) ; } this . thriftConnectionPartition . getPoolWatchThreadSignalQueue ( ) . take ( ) ; if ( ! run ) { break ; } maxNewConnections = this . thriftConnectionPartition . getMaxConnections ( ) - this . thriftConnectionPartition . getCreatedConnections ( ) ; } if ( maxNewConnections > 0 && ! this . thriftConnectionPool . poolShuttingDown ) { fillConnections ( Math . min ( maxNewConnections , this . thriftConnectionPartition . getAcquireIncrement ( ) ) ) ; if ( this . thriftConnectionPartition . getCreatedConnections ( ) < this . thriftConnectionPartition . getMinConnections ( ) ) { fillConnections ( this . thriftConnectionPartition . getMinConnections ( ) - this . thriftConnectionPartition . getCreatedConnections ( ) ) ; } } if ( this . thriftConnectionPool . poolShuttingDown ) { return ; } } catch ( InterruptedException e ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Terminating pool watch thread" ) ; } return ; } } }
/*
@see java.lang.Runnable#run()