@Test
  public void testAsync() {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final AtomicInteger waitingToClose = new AtomicInteger(0);

    final int SOCKET_COUNT = 100;
    final int REMOTE_CLIENT_COUNT = 200;

    List<Socket> trackedSockets = new ArrayList<>();
    // Schedule a 100 sockets for async close.
    // They should all be stuck on countDownLatch.
    for (int i = 0; i < REMOTE_CLIENT_COUNT; i++) {
      Socket[] aSockets = new Socket[SOCKET_COUNT];
      String address = i + "";
      for (int j = 0; j < SOCKET_COUNT; j++) {
        aSockets[j] = createClosableSocket();
        trackedSockets.add(aSockets[j]);
        socketCloser.asyncClose(aSockets[j], address, () -> {
          try {
            waitingToClose.incrementAndGet();
            countDownLatch.await(5, TimeUnit.MINUTES);
          } catch (InterruptedException e) {
            throw new RuntimeException(e);
          }
        });
      }
    }

    // close the socketCloser first to verify that the sockets
    // that have already been scheduled will be still be closed.
    socketCloser.close();
    countDownLatch.countDown();
    // now all the sockets should get closed; use a wait criteria
    // since a thread pool is doing to closes
    await().until(() -> {
      boolean areAllClosed = true;
      for (Iterator<Socket> iterator = trackedSockets.iterator(); iterator.hasNext();) {
        Socket socket = iterator.next();
        if (socket.isClosed()) {
          iterator.remove();
          continue;
        }
        areAllClosed = false;
      }
      return areAllClosed;
    });
  }
Test that close requests are async.
geode-core/src/integrationTest/java/org/apache/geode/internal/net/SocketCloserIntegrationTest.java