Concurrency vs Parallelism — Concept Check
Questions on Concurrency vs Parallelism. Concurrency is about dealing with multiple tasks at once by interleaving progress; parallelism is about doing multiple tasks simultaneously using multiple CPU cores.
Questions in this quiz
8 questions on Concurrency vs Parallelism — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A single-core CPU is running multiple threads for an application. What is this an example of?
- ANeither concurrency nor parallelism
- BConcurrency
- CBoth concurrency and parallelism
- DParallelism
2.Your application experiences high CPU usage, and you notice multiple threads are being scheduled on a single-core processor. What is likely happening?
- AThe system is using parallelism to execute tasks.
- BThe system is using both concurrency and parallelism.
- CThe system is idle and not processing tasks.
- DThe system is using concurrency to manage tasks.
3.You have a CPU-bound task and decide to use Java parallel streams. What is the expected outcome on a multi-core machine?
- ATasks execute sequentially on a single core.
- BTasks execute simultaneously on multiple cores.
- CTasks execute faster due to reduced context switching.
- DTasks execute slower due to increased context switching.
4.A developer claims that using multiple threads on a single-core CPU will speed up a CPU-bound task. What is the flaw in this reasoning?
- ASingle-core CPUs can execute tasks simultaneously.
- BConcurrency allows parallel execution, speeding up tasks.
- CConcurrency doesn't speed up CPU-bound tasks on a single core.
- DMultiple threads always lead to faster execution.
5.You observe that an I/O-bound application performs better with many threads on a single-core machine. Why?
- AParallelism speeds up I/O operations.
- BConcurrency allows overlapping I/O and computation.
- CI/O operations are inherently faster with more threads.
- DMultiple cores handle I/O more efficiently.
6.In Java, which feature would you use to achieve parallelism for a CPU-bound task?
- AMultiple threads on a single core
- BSynchronized methods
- CParallel streams
- DSingle-threaded execution
7.Your application runs on a multi-core machine, but you notice tasks are not executing simultaneously. What might be the reason?
- AThe machine has insufficient cores for parallelism.
- BThe application is using concurrency, not parallelism.
- CThe application is CPU-bound and cannot parallelize.
- DThe application is using parallelism, not concurrency.
8.What is the main advantage of using concurrency for I/O-bound tasks on a single-core CPU?
- AConcurrency increases CPU speed.
- BConcurrency allows overlapping of I/O and computation.
- CConcurrency eliminates the need for context switching.
- DConcurrency reduces the need for parallelism.