Volatile là không đủ nếu trong trường hợp nhiều Thread cùng ĐỌC và GHI dữ liệu vào Main Memory. Lúc này cần phải sử dụng Synchornized để đảm bảo tính đồng bộ
As I have mentioned earlier, if two threads are both reading and writing to a shared variable, then using the volatile keyword for that is not enough. You need to use a synchronized in that case to guarantee that the reading and writing of the variable is atomic. Reading or writing a volatile variable does not block threads reading or writing. For this to happen you must use the synchronized keyword around critical sections.
THẢO LUẬN
ffffffffffffffff
ffffffffffff
fffffffff
fffffffffff
fffffffffff
ffffffffffffffff
fffffffff
fffffff
ffffffff
ffffffffffff
ffffffffff
ffffffff
ffffffffff
fffff
ffffffffff
fadfdfa
adfadfa
sdsedf
upvoted... ^^
Volatile là không đủ nếu trong trường hợp nhiều Thread cùng ĐỌC và GHI dữ liệu vào Main Memory. Lúc này cần phải sử dụng Synchornized để đảm bảo tính đồng bộ

