I want to write an asynchronous method that returns a CompletableFuture. The only purpose of the future is to track when the method is complete, not its result. Would it be better to return CompletableFuture<Void> or CompletableFuture<?>? Is there a reason to prefer one or the other, or are they interchangeable?
CompletableFutureitself returnsCompletableFuture<Void>from many of its methods.java.niohas aFuture<Void>inAsynchronousSocketChannel:Future<Void> connect(SocketAddress remote).- On the other hand,
java.util.concurrentclasses likeExecutorServiceandScheduledExecutorServicereturnFuture<?>: for instance, withFuture<?> submit(Runnable task).
Note that I'm only asking about return types, not parameter lists, variable declarations, or other contexts.