public boolean acquire(double amount, boolean fastFail) {
        double waitTime = 0.0;

        synchronized (this) {
            // If rate limiting is not enabled, we technically have an uncapped limit
            if (!enabled) {
                return true;
            }

            refill();

            double originalCapacity = currentCapacity;
            double unfulfilled = tryAcquireCapacity(amount);

            if (unfulfilled > 0.0 && fastFail) {
                currentCapacity = originalCapacity;
                return false;
            }

            // If all the tokens couldn't be acquired immediately, wait enough
            // time to fill the remainder.
            if (unfulfilled > 0) {
                waitTime = unfulfilled / fillRate;
            }
        }

        if (waitTime > 0) {
            sleep(waitTime);
        }

        return true;
    }
Acquire tokens from the bucket. If the bucket contains enough capacity
to satisfy the request, this method will return immediately. Otherwise,
the behavior depends on the value of {@code fastFail}. If it is {@code
true}, then it will return {@code false} immediately, signaling that
enough capacity could not be acquired. Otherwise if {@code fastFail} is
{@code false}, then it will wait the required amount of time to fill the
bucket with enough tokens to satisfy {@code amount}.
<pre>
_TokenBucketAcquire(amount)
  # Client side throttling is not enabled until we see a throttling error.
  if not enabled
    return

  _TokenBucketRefill()
  # Next see if we have enough capacity for the requested amount.
  if amount <= current_capacity
    current_capacity = current_capacity - amount
  else
    sleep((amount - current_capacity) / fill_rate)
    current_capacity = current_capacity - amount
  return
</pre>

@param amount The amount of tokens to acquire.
@param fastFail Whether this method should return immediately instead
                of waiting if {@code amount} exceeds the current
                capacity.

@return Whether the amount was successfully acquired.
aws-java-sdk-core/src/main/java/com/amazonaws/internal/TokenBucket.java