code: public static synchronized UIServer getInstance(boolean multiSession, Function<String, StatsStorage> statsStorageProvider)
          throws RuntimeException {
          if (uiServer == null || uiServer.isStopped()) {
              PlayUIServer playUIServer = new PlayUIServer(PlayUIServer.DEFAULT_UI_PORT, multiSession);
              playUIServer.setMultiSession(multiSession);
              if (statsStorageProvider != null) {
                  playUIServer.autoAttachStatsStorageBySessionId(statsStorageProvider);
              }
              playUIServer.runMain(new String[] {});
              uiServer = playUIServer;
          } else if (!uiServer.isStopped()) {
              if (multiSession && !uiServer.isMultiSession()) {
                  throw new RuntimeException("Cannot return multi-session instance." +
                          " UIServer has already started in single-session mode at " + uiServer.getAddress() +
                          " You may stop the UI server instance, and start a new one.");
              } else if (!multiSession && uiServer.isMultiSession()) {
                  throw new RuntimeException("Cannot return single-session instance." +
                          " UIServer has already started in multi-session mode at " + uiServer.getAddress() +
                          " You may stop the UI server instance, and start a new one.");
              }
          }
          return uiServer;
      }
docs: Get (and, initialize if necessary) the UI server.
  Singleton pattern - all calls to getInstance() will return the same UI instance.
  @param multiSession in multi-session mode, multiple training sessions can be visualized in separate browser tabs.
  <br/>URL path will include session ID as a parameter, i.e.: /train becomes /train/:sessionId
  @param statsStorageProvider function that returns a StatsStorage containing the given session ID.
  <br/>Use this to auto-attach StatsStorage if an unknown session ID is passed
  as URL path parameter in multi-session mode, or leave it {@code null}.
  @return UI instance for this JVM
  @throws RuntimeException if the instance has already started in a different mode (multi/single-session)