client.startAsync(new Consumer<TorrentSessionState> { void accept(TorrentSessionState state) { if (state.getPiecesRemaining() == 0) { client.stop(); } } }, 1000).join();