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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to