private void doCreate(final Url url, final ConnectionPool pool, final String taskName,
                          final int syncCreateNumWhenNotWarmup) throws RemotingException {
        final int actualNum = pool.size();
        final int expectNum = url.getConnNum();
        if (actualNum >= expectNum) {
            return;
        }
        if (logger.isDebugEnabled()) {
            logger.debug("actual num {}, expect num {}, task name {}", actualNum, expectNum,
                taskName);
        }
        if (url.isConnWarmup()) {
            for (int i = actualNum; i < expectNum; ++i) {
                Connection connection = create(url);
                pool.add(connection);
            }
        } else {
            if (syncCreateNumWhenNotWarmup < 0 || syncCreateNumWhenNotWarmup > url.getConnNum()) {
                throw new IllegalArgumentException(
                    "sync create number when not warmup should be [0," + url.getConnNum() + "]");
            }
            // create connection in sync way
            if (syncCreateNumWhenNotWarmup > 0) {
                for (int i = 0; i < syncCreateNumWhenNotWarmup; ++i) {
                    Connection connection = create(url);
                    pool.add(connection);
                }
                if (syncCreateNumWhenNotWarmup >= url.getConnNum()) {
                    return;
                }
            }

            pool.markAsyncCreationStart();// mark the start of async
            try {
                this.asyncCreateConnectionExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            for (int i = pool.size(); i < url.getConnNum(); ++i) {
                                try {
                                    Connection conn = create(url);
                                    pool.add(conn);
                                } catch (RemotingException e) {
                                    logger
                                        .error(
                                            "Exception occurred in async create connection thread for {}, taskName {}",
                                            url.getUniqueKey(), taskName, e);
                                    if (pool.isEmpty()) {
                                        connTasks.remove(url.getUniqueKey());
                                        break;
                                    }
                                }
                            }
                        } finally {
                            pool.markAsyncCreationDone();// mark the end of async
                        }
                    }
                });
            } catch (RejectedExecutionException e) {
                pool.markAsyncCreationDone();// mark the end of async when reject
                throw e;
            }
        } // end of NOT warm up
    }
do create connections

@param url target url
@param pool connection pool
@param taskName task name
@param syncCreateNumWhenNotWarmup you can specify this param to ensure at least desired number of connections available in sync way
@throws RemotingException
src/main/java/com/alipay/remoting/DefaultConnectionManager.java