I wondered if you might have tackled it elsewhere, but when I attempt to use the .sleep() method, it says that an InterruptedException can be thrown. Now I can handle this by either adding it to the method signature, or use a try-catch block. Now when I use a try-catch block, there is a warning that it is not enough to simply ignore the exception that is thrown, it needs to be re-thrown or interrupted. I have used something along the lines of: ``` ... try { TimeUnit.x.sleep(y); } catch (InterruptedException e) { Thread.currentThread.interrupt(); } ... ``` Now I have no idea what the reason is behind this, and then when I have tried to throw the InterruptedException, it asks me to surround it in a try catch block inside the catch block. Not sure if this is thread specific, and if you covered it anywhere else, or able to cover it. Thanks in advance for any information.
First, you just gave me an idea for a video! Thanks :) And to briefly answer your question, yes what you are doing is the way to go, and that's because each thread has kind of an "interrupted" flag, and if you simply ignore the exception, the thread's interrupted flag will not be set, and it will continue executing as if nothing happened, or that thread won't be handled appropriately by other threads. By calling this method in the catch block, you are setting the interrupted flag on the thread that was interrupted, allowing other parts of your code to check it and handle the thread appropriately. Hope this partly answers it, and stay tuned for more videos!
Hands down the best explanation of completable futures out there. You're a master at explaining difficult concepts
Thanks! Glad it helped :)
Great explanation, better than other guides on the internet.
This explanation is amazing and so clear. Thank you.
That was the best explamnation so far! Thank you very much!
excellent tutorial! thank you!
Glad it was helpful!
So cool, at last. Thanks a lot!
Excellent information
Thanks so much for this video it helped alot. This is the best one yet. i tried all the other videos and this one made it clear
Enjoyable explanation. Thanks a lot.
amazing video
Such a wonderful explanation with good examples of each scenario, definitely you get to the point!, you get a new suscriber!
Excellent Explanation !
great explanation
Really helpful
Can u make a video on writing test cases for CompletableFutures
Will add it to my list, stay tuned!
@geekific dude, your videos are jewels.
Thank you!!! Great topic and explanation of it.
Liked and subscribed...
Please create video on fork and join
Perfect Thanks a lot !
Glad it was helpful!
Thanks a lot
I wondered if you might have tackled it elsewhere, but when I attempt to use the .sleep() method, it says that an InterruptedException can be thrown. Now I can handle this by either adding it to the method signature, or use a try-catch block. Now when I use a try-catch block, there is a warning that it is not enough to simply ignore the exception that is thrown, it needs to be re-thrown or interrupted.
I have used something along the lines of:
```
...
try {
TimeUnit.x.sleep(y);
} catch (InterruptedException e) {
Thread.currentThread.interrupt();
}
...
```
Now I have no idea what the reason is behind this, and then when I have tried to throw the InterruptedException, it asks me to surround it in a try catch block inside the catch block.
Not sure if this is thread specific, and if you covered it anywhere else, or able to cover it.
Thanks in advance for any information.
First, you just gave me an idea for a video! Thanks :)
And to briefly answer your question, yes what you are doing is the way to go, and that's because each thread has kind of an "interrupted" flag, and if you simply ignore the exception, the thread's interrupted flag will not be set, and it will continue executing as if nothing happened, or that thread won't be handled appropriately by other threads. By calling this method in the catch block, you are setting the interrupted flag on the thread that was interrupted, allowing other parts of your code to check it and handle the thread appropriately. Hope this partly answers it, and stay tuned for more videos!
Great explanation