有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    您需要的是一个“fire and forget”语义,它与http请求没有直接关系,而更多地与线程有关。只需在新的线程中启动任何任务

    Thread thread = new Thread(new Runnable(){
      @Override
      public void run(){
        HttpURLConnectionExample http = new HttpURLConnectionExample();
        System.out.println("Testing 1 - Send Http GET request");
        http.sendGet();
      }
    });
    thread.start();