โ† All SCJP Flashcard Decks

Java Threads and Concurrency Flashcards

6 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 6 Java Threads and Concurrency flashcards as text
  1. What happens when `Thread.start()` is called more than once on the same Thread object?

    Answer: An IllegalThreadStateException is thrown

    Once a thread has been started and has terminated, calling `start()` again on the same Thread object throws `IllegalThreadStateException`.

  2. Which interface should be implemented to return a result from a thread's execution?

    Answer: Callable

    `Callable` is similar to `Runnable` but its `call()` method returns a result of type V and can throw checked exceptions.

  3. What is thread starvation in Java?

    Answer: A thread being perpetually denied CPU access due to other higher-priority threads

    Thread starvation occurs when a thread cannot gain regular access to shared resources because other threads are always prioritized.

  4. Which keyword modifier ensures a method can only be executed by one thread at a time, locking on the instance?

    Answer: synchronized

    An instance `synchronized` method acquires the monitor lock of `this` object, preventing concurrent execution by multiple threads.

  5. What is the purpose of `Thread.join()` in Java?

    Answer: To make the current thread wait until the specified thread finishes

    `Thread.join()` causes the calling thread to block until the thread on which `join()` was called completes its execution.

  6. Which concurrent collection class is designed for high-concurrency scenarios and partitions its data to reduce lock contention?

    Answer: ConcurrentHashMap

    `ConcurrentHashMap` uses segment-level (or node-level in Java 8+) locking for better throughput than a fully synchronized map.

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