Concurrency 3 Flashcards
What is stale data? What causes it?
Stale data is data that is not up to date. It is caused by data inconsistency.
What causes data inconsistency?
Thread communication issues such as deadlock, live lock and starvation.
Implementing correct thread management ensures…
Fresh data is maintained across the program. Fresh data means that data is consistent.
Define Atomic Variables…
Atomic Variables are ones which are to be operated in by atomic actions. When modified, these variables have no intermediate state, thus are immune to becoming stale.
What determines whether to use Synchronised or Atom Actions?
Synchronised - Use when there is a large code block, as the entirety of the object is locked which is a cumbersome process.
Atomic Action - Used when only a small section of the program (i.e some variables) need to be updated. This is a lightweight process.
How does the volatile keyword ensure data freshness?
When volatile is used, the variable will change consistently across all threads when updated. This removes the possibility of data inconsistency.
Define publishing an object…
Publishing an object means to make the object visible from outside its current scope.
Define escaping an object…
When an object escaped, it means it unintentionally becomes viewable from outside its local scope.
Define Thread confinement…
This is to store the static data of a program in a single thread that wont change.