I have a piece of Java code with two
s, like so:
CompletableFuture<Boolean> future1 = CompletableFuture.supplyAsync(() ->
CompletableFuture<Boolean> future2 = CompletableFuture.supplyAsync(() ->
I want to race these two
s and take the first resulting Boolean and store it in a variable. However, I would also like to ensure that neither future runs for longer than 60 seconds (although this is unnecessary). I then want to ensure that both of these
s are killed, and my program resumes on just the main thread.
How could I pull this off simply and reliably? Or, am I using the wrong tools for the job at hand?