szetszwo commented on PR #8022:
URL: https://github.com/apache/ozone/pull/8022#issuecomment-2714852242

   > 1. Change from CompletableFuture to Future
   
   @sumitagrawl , please try the following.  CompletableFuture, which 
implements Future, can be cancelled.
   ```java
     public static void main(String[] args) throws InterruptedException {
       CompletableFuture<Object> task = CompletableFuture.supplyAsync(() -> {
         for (int i = 0; ; i++) {
           System.out.println(i);
           try {
             Thread.sleep(1000);
           } catch (InterruptedException e) {
             throw new RuntimeException(e);
           }
         }
       });
   
       Thread.sleep(3000);
       final boolean cancelled = task.cancel(true);
       System.out.println(cancelled);
       System.out.println(task.isCancelled());
     }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to