- Process : unit of launch from the viewpoint of OS
- each process maintains isolated memory space
- Thread : unit of execution within processes
- All threads share same process => needs concurrency
- Assume OS threads, as opposed to user-level threads(maintained by user level library ; e.g. Green Threads in early Java)
- Regarding visibility of write effects (assure write-after-read)
Each action in a thread happens-before every other subsequent action in same thread.
if A -> B -> C, then A -> C
Each time the variable must be stored/read from the main memory (invalidates cache!) (ref: link)
Note that, volatie vs atomic vs synchronized is all different. (ref : link)
Lock i = ~
i.lock()
try {
}
finally {
i.unlock()
}
OR
synchronized block : foo.synchronized { }
This rule ensures that unlock -> lock, otherwise, deadlock.
Each execution barrier located at thread start / join