Concurrency vs Parallel
Process vs Thread
Synchronization
Race Condition / Mutual Exclusion / Critical Section / Lock (read write lock) / Mutex
Atomicity
Concurrency: multiple tasks theoretically run simultaneously, semantic 假装看起来是,running multiple tasks on single core(假装是)fake multi task.
Logical flows overlap in time(life cycle)
a b a → b → a
Parallel: multiple tasks physically run simultaneously, at least two executors, implementation 事实上,running multiple tasks on multiple cores, real multi tasks
Single Core CPU? concurrency task1 task2 task1?
Process: independent executor of instructions exclusive CPU, independent their own memory private memory(address) / stack / heap
access a complete memory space
IPC(
Inter-process communication
) to communicate, no problem
Thread: independent executor of instructions, shared memory → shared heap
private stack, register status, context…
shared memory to communicate → concurrency
read / write heap ? what happen?
whether they have independent memory (share data code)
independent e
Executor Service
https://www.baeldung.com/java-executor-service-tutorial
Difference between-binary-semaphore-and-mutex
https://stackoverflow.com/questions/62814/difference-between-binary-semaphore-and-mutex
independent e
Executor Service
https://www.baeldung.com/java-executor-service-tutorial
ExecutorService vs. Fork/Join
After the release of Java 7, many developers decided that the ExecutorService framework should be replaced by the fork/join framework. This is not always the right decision, however. Despite the simplicity of usage and the frequent performance gains associated with fork/join, there is also a reduction in the amount of developer control over concurrent execution.
ExecutorService gives the developer the ability to control the number of generated threads and the granularity of tasks which should be executed by separate threads. The best use case for ExecutorService is the processing of independent tasks, such as transactions or requests according to the scheme “one thread for one task.”
In contrast, according to Oracle’s documentation, fork/join was designed to speed up work which can be broken into smaller pieces recursively.
Difference between-binary-semaphore-and-mutex
https://stackoverflow.com/questions/62814/difference-between-binary-semaphore-and-mutex
No comments:
Post a Comment