Похожие чаты

Guys is copyOnwriteArrayList blocking or?

10 ответов

17 просмотров

you mean thread safe?

skittles- Автор вопроса

Its just regular ArrayList but thread safe

Yes, it's blocking. Blocks on all writes. And I found that out by just looking at the code. I don't know any other way to find it out if that is not specified in the docs.

skittles- Автор вопроса
Nader Jafari
Its just regular ArrayList but thread safe

If only that "but thread safe" was a simple annotation you put on a class, and boom - it magically becomes thread safe))) But it's not. And the main part of the story is that there many different ways to make it thread safe. CopyOnWrite principle is one of such ways, but it's not the only one. And it works differently from let's say Collections.SynchronizedList.

skittles
lol you took liberty to look at the code XD

I have my IDE in front of me, and giving it a glance is even faster than writing you back))

skittles- Автор вопроса
Dmytro Buryak
If only that "but thread safe" was a simple annota...

btw i am read it somewhere that it does not blocks

Dmytro Buryak
If only that "but thread safe" was a simple annota...

doesnt change the fact that is ArrayList but thread safe

Nader Jafari
doesnt change the fact that is ArrayList but thre...

Right. You can say the same that Collections.SynchronizedMap and ConcurrentHashMap are both maps but thread safe. Both designed to be thread safe. But they behave very differently in terms of performance and some specific behavior when you use them. And that's exactly what original question was about. It was not whether it's thread safe or not. But it was about how it behaves.

Похожие вопросы

Обсуждают сегодня

Карта сайта