Como matar os tópicos relacionados ao CompletableFuture?

Eu tenho um método que está verificando o tempo de execução CompletableFuture. Se esse CompletableFuture estiver em execução por mais de 2 segundos, eu quero matar esta tarefa. Mas como posso fazer isso se não tenho controle sobre o thread onde os métodos CompletableFuture são executados?

       final CompletableFuture<List<List<Student>>> responseFuture = new CompletableFuture<>();
responseFuture.supplyAsync(this::createAllRandomGroups)
        .thenAccept(this::printGroups)
        .exceptionally(throwable -> {
            throwable.printStackTrace();
            return null;
        });

createAllRandomGroups ()

private List<List<Student>> createAllRandomGroups() {
    System.out.println("XD");
    List<Student> allStudents = ClassGroupUtils.getActiveUsers();
    Controller controller = Controller.getInstance();
    List<List<Student>> groups = new ArrayList<>();
    int groupSize = Integer.valueOf(controller.getGroupSizeComboBox().getSelectionModel().getSelectedItem());
    int numberOfGroupsToGenerate = allStudents.size() / groupSize;
    int studentWithoutGroup = allStudents.size() % groupSize;
    if (studentWithoutGroup != 0) groups.add(this.getListOfStudentsWithoutGroup(allStudents, groupSize));
    for(int i = 0; i < numberOfGroupsToGenerate; i++) {
        boolean isGroupCreated = false;
        while (!isGroupCreated){
            Collections.shuffle(allStudents);
            List<Student> newGroup = this.createNewRandomGroupOfStudents(allStudents, groupSize);
            groups.add(newGroup);
            if (!DataManager.isNewGroupDuplicated(newGroup.toString())) {
                isGroupCreated = true;
                allStudents.removeAll(newGroup);
            }
        }
    }
    DataManager.saveGroupsToCache(groups);
    return groups;
}

printGroups ()

private void printGroups(List<List<Student>> lists) {
        System.out.println(lists);

    }

Esta afirmaçãoresponseFuture.cancel(true); não mata o thread em que responseFuture está executando os métodos. Então, qual é a maneira mais elegante de encerrar o thread CompletableFuture?

questionAnswers(2)

yourAnswerToTheQuestion