Java Threads and Concurrency Flashcards
7 cards from real SCJP practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Java Threads and Concurrency flashcards as text
What is the role of the `Executor` framework in Java concurrency?
Answer: It provides a higher-level API for managing thread creation and execution
The `Executor` framework decouples task submission from thread management, enabling thread pooling and flexible execution policies.
Which interface must be implemented to submit a task to an `ExecutorService` that returns a result?
Answer: Callable
`Callable` is like `Runnable` but its `call()` method returns a value and can throw checked exceptions.
A thread is in the TIMED_WAITING state. Which call most likely caused this?
Answer: synchronized(obj) { obj.wait(5000); }
Calling `wait(timeout)` with a positive timeout places the thread in TIMED_WAITING until the timeout expires or it is notified.
What exception is thrown when a thread that is blocked in `sleep()` or `wait()` has its `interrupt()` method called?
Answer: InterruptedException
`InterruptedException` is a checked exception thrown when a thread's interrupted status is set while it is blocked in a wait, sleep, or join.
Which `java.util.concurrent` class implements a blocking queue that can be used for producer-consumer problems?
Answer: LinkedBlockingQueue
`LinkedBlockingQueue` blocks the producer when full and the consumer when empty, making it ideal for producer-consumer scenarios.
What does the `join()` method on a Thread object do?
Answer: Causes the calling thread to wait until the target thread has finished executing
Calling `threadA.join()` blocks the calling thread until `threadA` completes, allowing threads to coordinate completion order.
Which statement about the `synchronized` keyword applied to a static method is correct?
Answer: It locks on the Class object associated with the declaring class
A synchronized static method acquires the intrinsic lock on the `Class` object, so all instances share the same lock for that method.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy