കാണിക്കല്‍ മാത്രം.
0:03
S… Speaker 2 (15- Waiting for the First Task)
Let's say there are two ways to get the current weather in a given city.
0:06
S… Speaker 2 (15- Waiting for the First Task)
Perhaps we have two different remote services,
0:09
S… Speaker 2 (15- Waiting for the First Task)
but sometimes one of these services responds a little bit slower.
0:13
S… Speaker 2 (15- Waiting for the First Task)
So we want to call these services concurrently and as soon as we get a response,
0:17
S… Speaker 2 (15- Waiting for the First Task)
we're going to display it to the user.
0:19
S… Speaker 2 (15- Waiting for the First Task)
Let me show you how to do that.
0:20
S… Speaker 2 (15- Waiting for the First Task)
So I'm going to create two completable futures.
0:23
S… Speaker 2 (15- Waiting for the First Task)
Here's the first one completable future that supply async.
0:28
S… Speaker 2 (15- Waiting for the First Task)
Let's say this is our slow link.
0:31
S… Speaker 1 (15- Waiting for the First Task)
So
0:32
S… Speaker 2 (15- Waiting for the First Task)
in the body of this lambda,
0:34
S… Speaker 2 (15- Waiting for the First Task)
I'm going to call long task that simulate and
0:38
S… Speaker 2 (15- Waiting for the First Task)
then return 20.
0:39
S… Speaker 2 (15- Waiting for the First Task)
That is the current weather,
0:40
S… Speaker 2 (15- Waiting for the First Task)
let's say in New York City.
0:42
S… Speaker 2 (15- Waiting for the First Task)
Now we create a second task completable
0:46
S… Speaker 2 (15- Waiting for the First Task)
future that supply async.
0:48
S… Speaker 2 (15- Waiting for the First Task)
Now this simulates a fast link.
0:50
S… Speaker 2 (15- Waiting for the First Task)
So here we return 20 immediately.
0:53
S… Speaker 2 (15- Waiting for the First Task)
Now we're going to call both these services concurrently.
0:56
S… Speaker 2 (15- Waiting for the First Task)
And as soon as one of them respond,
0:58
S… Speaker 2 (15- Waiting for the First Task)
we're going to print the result on the terminal.
1:00
S… Speaker 1 (15- Waiting for the First Task)
So
1:02
S… Speaker 2 (15- Waiting for the First Task)
Here we call completable future dot in the last
1:06
S… Speaker 2 (15- Waiting for the First Task)
video you learned about all of with this we can wait for the completion of all tasks.
1:10
S… Speaker 2 (15- Waiting for the First Task)
We have another method called any of this returns
1:14
S… Speaker 2 (15- Waiting for the First Task)
a new completable future that will complete as soon as one of these
1:18
S… Speaker 2 (15- Waiting for the First Task)
completable futures that we pass here completes.
1:21
S… Speaker 2 (15- Waiting for the First Task)
So just like before we have var arcs here we
1:25
S… Speaker 2 (15- Waiting for the First Task)
can pass any number of completable futures.
1:27
S… Speaker 2 (15- Waiting for the First Task)
I'm going to pass first and second.
1:30
S… Speaker 2 (15- Waiting for the First Task)
This will give us a new completable future.
1:33
S… Speaker 2 (15- Waiting for the First Task)
Let's store it in this variable fastest.
1:37
S… Speaker 2 (15- Waiting for the First Task)
Look at the type of this variable.
1:38
S… Speaker 2 (15- Waiting for the First Task)
It's a completable future of object.
1:41
S… Speaker 1 (15- Waiting for the First Task)
Now,
1:43
S… Speaker 2 (15- Waiting for the First Task)
right after we get the result,
1:45
S… Speaker 2 (15- Waiting for the First Task)
we can call then accept.
1:48
S… Speaker 2 (15- Waiting for the First Task)
We're going to consume the result.
1:50
S… Speaker 2 (15- Waiting for the First Task)
So we get the temperature and print it on a terminal.
1:54
S… Speaker 1 (15- Waiting for the First Task)
Now,
1:57
S… Speaker 2 (15- Waiting for the First Task)
let's reformat our code.
1:59
S… Speaker 2 (15- Waiting for the First Task)
That is better.
2:00
S… Speaker 1 (15- Waiting for the First Task)
So,
2:01
S… Speaker 2 (15- Waiting for the First Task)
run.
2:03
S… Speaker 2 (15- Waiting for the First Task)
See, we got the result immediately.
2:06
S… Speaker 2 (15- Waiting for the First Task)
We didn't have to wait three seconds to get the current weather from our slow service.

ഈ അക്ഷം AI (സ്വയമുണ്ടായി അക്ഷരാനുഗ്രഹം) ഉണ്ടാക്കിയത്. പിശകുകള്‍ ഉള്‍ക്കൊള്ളാം. അല്ലെങ്കില്‍ മൂല ഓഡിയോ ഉപയോഗിക്കുന്നതിനു് മുന്‍കൂട്ടിയുള്ള പിശകുകള്‍ സ്ഥിതീകരിക്കാം. ഐഐ നയം

❤️ സ്നേഹം STT.ai? കൂട്ടുകാരോട് പറയൂ!
സാരാംശം
ഈ അക്ഷരമാലയുടെ AI സമ്മറി ഉണ്ടാക്കാന്‍ കെസ്റ്റെല്‍ ക്ലിക്ക് ചെയ്യുക.
സഖാവ്...
ഈ ട്രാന്‍സ്പെക്റ്റിനെ കുറിച്ച് AI ചോദിയ്ക്കുക
ഈ പുസ്‌തകത്തെക്കുറിച്ച് എന്തെങ്കിലും ചോദിക്കുക — AI - ന്‌ ആവശ്യമായ ഭാഗങ്ങൾ കണ്ടെത്തുകയും ഉത്തരം നൽകുകയും ചെയ്യും.