Avoiding a volatile state (with multithreading)

Multithreading is tough. The only thing you can do is program very carefully and follow good tips. One great piece of advice I received from the answers on this forum is to avoid a volatile state . I understand that this even applies in Erlang language. However, I do not see how this can be done without serious performance gains and a huge amount of caches.

For example. You have a large list of objects, each of which contains quite a few properties; in other words: a large data structure. Suppose you have a bunch of threads and they all need to access and modify the list. How can this be done without shared memory without caching the entire data structure in each thread?

Update: After reading these reactions, I would like to pay attention to performance. Don't you think that copying the same data will make the program slower than with shared memory?

+3
source share
6 answers

Not every algorithm can be successfully parallelized.

- " ", , .

, (, ), datastruct .

: .

+2

, : ? , ? , , ? , , ?

, , -. , , , , , . , , , , "!". :)

+1

. , , , , (.. , ).

, , , , . , . , , , . .

, (.. ), , , concurrency . , , , , , .

+1

- . , , .

+1

, - , , .

, , "", (, , , , NoOfMembers - , - - - , , , , )

In other threads, you only need to check one simple “update in progess” mutex only when they actively want to update.

+1
source

Source: https://habr.com/ru/post/1711475/


All Articles