コード例 #1
0
  public static void main(final String[] args) {

    final int port = Integer.valueOf(System.getProperty("port", "7657"));
    final int bossThreads = Integer.valueOf(System.getProperty("bossThreads", "1"));
    final int workerThreads = Integer.valueOf(System.getProperty("workerThreads", "1"));

    final HelloServer server = new HelloServer();
    server.start(port, bossThreads, workerThreads);

    Runtime.getRuntime().addShutdownHook(new Thread(server::stop));
  }
コード例 #2
0
  public static final void main(String[] args) {
    final ProtocolDecodingServer server = new ProtocolDecodingServer();
    server.init();

    System.out.println("Loop server started");
    // Bind  a shutdown hook
    Runtime.getRuntime()
        .addShutdownHook(
            new Thread() {
              @Override
              public void run() {
                server.stop();
              }
            });
  }