code: public void createTableIfNotExists(HBaseAdmin admin, byte[] tableName,
                                       HTableDescriptor tableDescriptor,
                                       byte[][] splitKeys,
                                       long timeout, TimeUnit timeoutUnit) throws IOException {
      if (admin.tableExists(tableName)) {
        return;
      }
      setDefaultConfiguration(tableDescriptor, admin.getConfiguration());
  
      String tableNameString = Bytes.toString(tableName);
  
      try {
        LOG.info("Creating table '{}'", tableNameString);
        // HBaseAdmin.createTable can handle null splitKeys.
        admin.createTable(tableDescriptor, splitKeys);
        LOG.info("Table created '{}'", tableNameString);
        return;
      } catch (TableExistsException e) {
        // table may exist because someone else is creating it at the same
        // time. But it may not be available yet, and opening it might fail.
        LOG.info("Failed to create table '{}'. {}.", tableNameString, e.getMessage(), e);
      }
  
      // Wait for table to materialize
      try {
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.start();
        long sleepTime = timeoutUnit.toNanos(timeout) / 10;
        sleepTime = sleepTime <= 0 ? 1 : sleepTime;
        do {
          if (admin.tableExists(tableName)) {
            LOG.info("Table '{}' exists now. Assuming that another process concurrently created it.", tableName);
            return;
          } else {
            TimeUnit.NANOSECONDS.sleep(sleepTime);
          }
        } while (stopwatch.elapsedTime(timeoutUnit) < timeout);
      } catch (InterruptedException e) {
        LOG.warn("Sleeping thread interrupted.");
      }
      LOG.error("Table '{}' does not exist after waiting {} ms. Giving up.", tableName, MAX_CREATE_TABLE_WAIT);
    }
docs: Create a hbase table if it does not exist. Deals with race conditions when two clients concurrently attempt to
  create the table.
  @param admin the hbase admin
  @param tableName the name of the table
  @param tableDescriptor hbase table descriptor for the new table
  @param timeout Maximum time to wait for table creation.
  @param timeoutUnit The TimeUnit for timeout.