multithreading - Are Thread Safety and Data Race condition addressing the same issue? -


i confused. understand, piece of code thread-safe if functions correctly during simultaneous execution multiple threads. , data race occurs when 2 instructions different threads access same memory location, @ least 1 of these accesses write , there no synchronization mandating particular order among these accesses.

its clear both relate concurrency. addressing same thing?

if program(or part) has data race, there high probability program not thread safe.

thread-safety declares ultimate property program, uses multithreading. checking property is difficult task , cannot fully performed automatically (because term correctness in multithreaded case badly formalized).

data race declares event, (relatively) easy check automatically, , having event has high correlation thread-unsafety.

summarized:

  1. no data race - program can be thread safe.
  2. data race - program unlikely thread safe.

some languages prohibit write programs data races. such languages:

  1. no data race - program can be thread safe.
  2. data race - program never thread safe.

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -