CPU Scheduling in Java — Concept Check
Questions on CPU Scheduling in Java. The JVM layers its own scheduling abstractions (thread priorities, ForkJoinPool, virtual threads) on top of OS CPU scheduling, giving Java developers several ways to control concurrency and task execution.
Questions in this quiz
7 questions on CPU Scheduling in Java — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A Java application using ForkJoinPool experiences high idle times. What could be the cause?
- AVirtual threads are not being used.
- BThe common pool size is too large.
- CThread priorities are not set correctly.
- DTasks are not evenly distributed across deques.
2.In a Java program, you need to schedule a task to run every 10 seconds. Which scheduler should you use?
- ACompletableFuture for asynchronous execution.
- BScheduledExecutorService with fixed-rate scheduling.
- CVirtual threads for lightweight tasks.
- DForkJoinPool for parallel execution.
3.A developer uses virtual threads for a CPU-bound task. What is a likely outcome?
- AIncreased context switching overhead.
- BImproved CPU utilization.
- CEfficient handling of blocking I/O.
- DReduced memory usage.
4.Which statement about Java thread priorities is true?
- AThey are consistent across all platforms.
- BThey guarantee OS-level priority mapping.
- CThey may not affect thread scheduling on all platforms.
- DThey influence ForkJoinPool task scheduling.
5.A service using CompletableFuture is experiencing delays. What might be a cause?
- AForkJoinPool is not utilized.
- BTasks are I/O-bound and blocking.
- CVirtual threads are not used.
- DScheduledExecutorService is misconfigured.
6.What happens when a ForkJoinPool thread runs out of tasks?
- AIt steals tasks from another thread's deque.
- BIt switches to a ScheduledExecutorService.
- CIt increases its priority to get more CPU time.
- DIt waits for new tasks to be submitted.
7.Which Java feature allows millions of lightweight threads to be scheduled on a small pool of OS threads?
- AForkJoinPool
- BCompletableFuture
- CVirtual threads
- DScheduledExecutorService