public Server choose(ILoadBalancer lb, Object key) {
		long requestTime = System.currentTimeMillis();
		long deadline = requestTime + maxRetryMillis;

		Server answer = null;

		answer = subRule.choose(key);

		if (((answer == null) || (!answer.isAlive()))
				&& (System.currentTimeMillis() < deadline)) {

			InterruptTask task = new InterruptTask(deadline
					- System.currentTimeMillis());

			while (!Thread.interrupted()) {
				answer = subRule.choose(key);

				if (((answer == null) || (!answer.isAlive()))
						&& (System.currentTimeMillis() < deadline)) {
					/* pause and retry hoping it's transient */
					Thread.yield();
				} else {
					break;
				}
			}

			task.cancel();
		}

		if ((answer == null) || (!answer.isAlive())) {
			return null;
		} else {
			return answer;
		}
	}
public Server choose ( ILoadBalancer lb , Object key ) { long requestTime = System . currentTimeMillis ( ) ; long deadline = requestTime + maxRetryMillis ; Server answer = null ; answer = subRule . choose ( key ) ; if ( ( ( answer == null ) || ( ! answer . isAlive ( ) ) ) && ( System . currentTimeMillis ( ) < deadline ) ) { InterruptTask task = new InterruptTask ( deadline - System . currentTimeMillis ( ) ) ; while ( ! Thread . interrupted ( ) ) { answer = subRule . choose ( key ) ; if ( ( ( answer == null ) || ( ! answer . isAlive ( ) ) ) && ( System . currentTimeMillis ( ) < deadline ) ) { Thread . yield ( ) ; } else { break ; } } task . cancel ( ) ; } if ( ( answer == null ) || ( ! answer . isAlive ( ) ) ) { return null ; } else { return answer ; } }
/*
Loop if necessary. Note that the time CAN be exceeded depending on the
subRule, because we're not spawning additional threads and returning
early.