code: private static BigInteger expandBigIntegerTenPowers(int n) {
          synchronized(BigDecimal.class) {
              BigInteger[] pows = BIG_TEN_POWERS_TABLE;
              int curLen = pows.length;
              // The following comparison and the above synchronized statement is
              // to prevent multiple threads from expanding the same array.
              if (curLen <= n) {
                  int newLen = curLen << 1;
                  while (newLen <= n)
                      newLen <<= 1;
                  pows = Arrays.copyOf(pows, newLen);
                  for (int i = curLen; i < newLen; i++)
                      pows[i] = pows[i - 1].multiply(BigInteger.TEN);
                  // Based on the following facts:
                  // 1. pows is a private local varible;
                  // 2. the following store is a volatile store.
                  // the newly created array elements can be safely published.
                  BIG_TEN_POWERS_TABLE = pows;
              }
              return pows[n];
          }
      }
docs: Expand the BIG_TEN_POWERS_TABLE array to contain at least 10**n.
  
  @param n the power of ten to be returned (>=0)
  @return a {@code BigDecimal} with the value (10<sup>n</sup>) and
  in the meantime, the BIG_TEN_POWERS_TABLE array gets
  expanded to the size greater than n.