- Tubelator AI
- >
- Videos
- >
- Science & Technology
- >
- #4 Java Programming CompletableFuture tutorial(Exception Handling)
#4 Java Programming CompletableFuture tutorial(Exception Handling)
Java 8 Completablefuture is an extension to Java's Future API which was introduced in Java 5.
In this tutorial series, you are going to learn how to use the Java 8 programming.
You are going to learn how to handle exceptions using Java completablefutures.
Completablefuture for asynchronous programming. You can use completable futures to run processes in the background using a different thread, thereby avoiding blocking the main thread.
You would learn how to use supply async, run async, then accept, then apply, exceptionally and much more.
#LemubitAcademy
Video Summary & Chapters
No chapters for this video generated yet.
Video Transcript
in the last lesson I showed you how to
use completely features run a sync and
supply a sink before we get on with this
very lesson let us demonstrate the trade
that these processes actually run what
do I mean by that
now in a process it's actually possible
checkout switched read that processes
running on I can actually print out
trade thoughts current trade this will
print out the current read this long
process is going to run on if I go on to
the main method and I write long little
process let's run this
so if you look at it it's running in the
main trade that is why it's blocking the
main trade when it takes some time to
other kids now this time let us use
completely features so if I say
completely future that supply async I
come over here and I run long natural
process I can put in six
and now see then accepts once the part
is ready let's print it out
all right so to make this really nice
let us sleep the main thread in its bits
over on this I guess it does
now the tread is in the pool
longer in the main thread that's just
proof that this is running on a
different thread I want to treat then
apply normally five continually feature
honestly supply I think I could have a a
long natural process and a 14-7
and sidon accepts once is ready you can
print it out that's fine let's say I
have a simple method picks in a value
now if that value is even to add 1 to
the value if it's not even a to I'll
treat the value on its own back the
value what will my go with is currently
if I come here of sleeping it'll let us
remove this trade statement since we
already know the trade is running on and
around this is going to print out 70 yes
because he collects 7 most long metal
process what applies it by 10 aren't
owns it so what if after a long metal
process probably I want to take the
value or con it a little bit probably do