5- Asynchronous Programming
Jul 03, 2026 23:01
· 1:50
· English
· Whisper Turbo
· 2 Qof-dheer
Qoraalkani wuxuu dhacayaa maanta.
Kordhinta kaydinta joogtada ah →
Soo bandhigida oo keliya
0:03
S…
Speaker 1 (5- Asynchronous Programming)
In the last video, I told you that this get method
0:06
S…
Speaker 1 (5- Asynchronous Programming)
is a blocking method.
0:07
S…
Speaker 1 (5- Asynchronous Programming)
When we call it,
0:08
S…
Speaker 1 (5- Asynchronous Programming)
the current thread has to wait until the result of this task is
0:12
S…
Speaker 1 (5- Asynchronous Programming)
ready. So even though we're executing this task in a separate thread,
0:16
S…
Speaker 1 (5- Asynchronous Programming)
we're making the current thread wait for the completion of that thread.
0:20
S…
Speaker 1 (5- Asynchronous Programming)
We're not using our threads properly,
0:22
S…
Speaker 1 (5- Asynchronous Programming)
we're wasting our threads.
0:23
S…
Speaker 1 (5- Asynchronous Programming)
Now this is a very simple application,
0:25
S…
Speaker 1 (5- Asynchronous Programming)
this is a command line application,
0:27
S…
Speaker 1 (5- Asynchronous Programming)
but if you had a mobile or a desktop app,
0:29
S…
Speaker 1 (5- Asynchronous Programming)
this main thread would be responsible for handling the UI events,
0:33
S…
Speaker 1 (5- Asynchronous Programming)
such as mouse clicks and keystrokes.
0:36
S…
Speaker 1 (5- Asynchronous Programming)
So if you make the main thread wait for the completion of another thread,
0:39
S…
Speaker 1 (5- Asynchronous Programming)
it's not going to be able to respond to the UI events.
0:42
S…
Speaker 1 (5- Asynchronous Programming)
The application window is going to freeze and the user is not going to be able to resize
0:46
S…
Speaker 1 (5- Asynchronous Programming)
or move it.
0:47
S…
Speaker 1 (5- Asynchronous Programming)
So to get the most out of our threads,
0:49
S…
Speaker 1 (5- Asynchronous Programming)
we should write code in a non -blocking way and that is what we call asynchronous
0:54
S…
Speaker 1 (5- Asynchronous Programming)
programming.
0:54
S…
Speaker 1 (5- Asynchronous Programming)
Asynchronous is one of those fancy computer science terms,
0:58
S…
Speaker 1 (5- Asynchronous Programming)
but basically it means non -blocking.
1:00
S…
Speaker 1 (5- Asynchronous Programming)
This code that we have here is synchronous code.
1:03
S…
Speaker 1 (5- Asynchronous Programming)
It's blocking.
1:04
S…
Speaker 1 (5- Asynchronous Programming)
We want to write code in a non -blocking way.
1:06
S…
Speaker 1 (5- Asynchronous Programming)
As a metaphor,
1:07
S…
Speaker 1 (5- Asynchronous Programming)
think of a restaurant.
1:08
S…
Speaker 1 (5- Asynchronous Programming)
When you go in a restaurant and order your food,
1:10
S…
Speaker 1 (5- Asynchronous Programming)
the waiter comes,
1:12
S…
Speaker 1 (5- Asynchronous Programming)
takes your order,
1:12
S…
Speaker 1 (5- Asynchronous Programming)
and passes it to the kitchen.
1:14
S…
Speaker 2 (5- Asynchronous Programming)
Now,
1:14
S…
Speaker 1 (5- Asynchronous Programming)
he doesn't have to sit there,
1:16
S…
Speaker 1 (5- Asynchronous Programming)
wait for the kitchen to prepare your food before serving another guest.
1:20
S…
Speaker 1 (5- Asynchronous Programming)
He can go serve someone else in the meantime.
1:22
S…
Speaker 1 (5- Asynchronous Programming)
So that waiter,
1:23
S…
Speaker 1 (5- Asynchronous Programming)
that resource is like a thread in our application.
1:26
S…
Speaker 1 (5- Asynchronous Programming)
We don't want to make our main thread or another thread wait for the
1:30
S…
Speaker 1 (5- Asynchronous Programming)
completion of another thread as much as possible.
1:32
S…
Speaker 1 (5- Asynchronous Programming)
So we want to orchestrate our tasks such that when a task completes,
1:36
S…
Speaker 1 (5- Asynchronous Programming)
another task can get executed asynchronously.
1:39
S…
Speaker 1 (5- Asynchronous Programming)
In 2014,
1:41
S…
Speaker 1 (5- Asynchronous Programming)
Java gave us a new tool for implementing this kind of applications,
1:45
S…
Speaker 1 (5- Asynchronous Programming)
asynchronous applications.
1:46
S…
Speaker 1 (5- Asynchronous Programming)
We're going to look at that next.
Qoraalkan waxaa abuuray AI (u aqoonsiga hadalka otomaatiga ah). Waxay ku jiri kartaa khaladaad — xaqiijin ka dhanka ah audio asalka ah ee isticmaalka muhiimka ah. Xeerka AI
Qiyaas
Riix Summarize in ay soo saaraan AI faahfaahin ka mid ah qoraalkan.
La iskugu soo uruurinayo...
Su'aal AI Ku saabsan this transcript
Su'aal wax kasta oo ku saabsan qoraalkan - AI ka heli doonaa qaybaha la xiriira iyo jawaab.