7- Concurrency Issues
Jul 03, 2026 14:43
· 2:08
· English
· Whisper Turbo
· 4 Đầu ghi
Bản ghi chép này hết hạn hôm nay.
Tăng cấp cho lưu trữ vĩnh viễn →
Chỉ hiển thị
0:03
S…
Speaker 3 (7- Concurrency Issues)
In all the examples I've shown you so far,
0:05
S…
Speaker 3 (7- Concurrency Issues)
our download threads have been isolated from each other.
0:08
S…
Speaker 1 (7- Concurrency Issues)
But in a real world scenario,
0:10
S…
Speaker 3 (7- Concurrency Issues)
sometimes our threads may need to access and modify shared resources.
0:14
S…
Speaker 1 (7- Concurrency Issues)
For example,
0:15
S…
Speaker 3 (7- Concurrency Issues)
when downloading files,
0:16
S…
Speaker 3 (7- Concurrency Issues)
each thread may report the number of bytes it has downloaded to a shared object.
0:21
S…
Speaker 2 (7- Concurrency Issues)
With this object,
0:22
S…
Speaker 3 (7- Concurrency Issues)
we can keep track of the entire download progress and report it to the user.
0:27
S…
Speaker 3 (7- Concurrency Issues)
Now, if multiple threads access the same object and at least one
0:31
S…
Speaker 3 (7- Concurrency Issues)
of them changes this object,
0:32
S…
Speaker 3 (7- Concurrency Issues)
we're going to run into a couple of issues.
0:34
S…
Speaker 3 (7- Concurrency Issues)
The first issue happens when multiple threads try to modify
0:38
S…
Speaker 3 (7- Concurrency Issues)
the same data at the same time.
0:40
S…
Speaker 3 (7- Concurrency Issues)
It's like having one burger and three people wanting to eat it at the same time.
0:44
S…
Speaker 1 (7- Concurrency Issues)
It's not going to work.
0:45
S…
Speaker 3 (7- Concurrency Issues)
So if multiple threads try to change the same data,
0:48
S…
Speaker 3 (7- Concurrency Issues)
we may get wrong results or our application may crash.
0:51
S…
Speaker 2 (7- Concurrency Issues)
When this happens,
0:52
S…
Speaker 3 (7- Concurrency Issues)
we say we have a race condition,
0:54
S…
Speaker 3 (7- Concurrency Issues)
which means multiple threads are racing or competing to modify some
0:58
S…
Speaker 1 (7- Concurrency Issues)
data.
0:58
S…
Speaker 3 (7- Concurrency Issues)
I will show you an example of this in the next video.
1:01
S…
Speaker 3 (7- Concurrency Issues)
Another issue happens when one thread changes the shared data,
1:05
S…
Speaker 3 (7- Concurrency Issues)
but the changes are not visible to other threads.
1:08
S…
Speaker 3 (7- Concurrency Issues)
So different threads will have different views of the shared data.
1:11
S…
Speaker 3 (7- Concurrency Issues)
This is what we call a visibility problem.
1:14
S…
Speaker 3 (7- Concurrency Issues)
So if multiple threads access the same data and at least one of them tries to
1:18
S…
Speaker 3 (7- Concurrency Issues)
change it, we're going to have some problems.
1:20
S…
Speaker 1 (7- Concurrency Issues)
If they only want to read the shared data,
1:22
S…
Speaker 3 (7- Concurrency Issues)
that's perfectly fine.
1:23
S…
Speaker 4 (7- Concurrency Issues)
And by the way,
1:24
S…
Speaker 3 (7- Concurrency Issues)
these problems are not specific to Java.
1:26
S…
Speaker 3 (7- Concurrency Issues)
These are properties of concurrent systems.
1:28
S…
Speaker 3 (7- Concurrency Issues)
We have the same problem in databases because multiple users can modify the
1:32
S…
Speaker 3 (7- Concurrency Issues)
same data at the same time.
1:34
S…
Speaker 3 (7- Concurrency Issues)
I talked about this in my ultimate SQL course.
1:37
S…
Speaker 3 (7- Concurrency Issues)
So if you want to build a multi -threaded application,
1:40
S…
Speaker 3 (7- Concurrency Issues)
you need to have a proper understanding of these problems and know how to prevent
1:44
S…
Speaker 3 (7- Concurrency Issues)
them. You should write code that can be safely executed by many threads
1:48
S…
Speaker 1 (7- Concurrency Issues)
in parallel.
1:49
S…
Speaker 1 (7- Concurrency Issues)
This is what we call thread safe code.
1:51
S…
Speaker 3 (7- Concurrency Issues)
It's one of those terms that you see in the Java documentation a lot.
1:55
S…
Speaker 1 (7- Concurrency Issues)
Some classes are thread safe,
1:57
S…
Speaker 3 (7- Concurrency Issues)
which means they can be safely used across many parallel threads.
2:00
S…
Speaker 1 (7- Concurrency Issues)
We'll talk about this later.
2:02
S…
Speaker 1 (7- Concurrency Issues)
So in the next video,
2:03
S…
Speaker 3 (7- Concurrency Issues)
I'm going to show you concurrency problems in action.
Bản ghi này được tạo bởi AI (tự động nhận dạng giọng nói). Có thể chứa lỗi — kiểm tra với âm thanh gốc để sử dụng quan trọng. Chính sách AI
Tóm tắt
Nhấn tổng hợp để tạo một tóm tắt AI của bản ghi này.
Tóm tắt...
Hỏi AI về bản ghi này
Hỏi bất cứ điều gì về bản ghi chép này - AI sẽ tìm thấy các phần liên quan và trả lời.