← All topics
Quiz: Java Concurrency Utilities: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. Why can two threads running count++ on a shared int lose updates?
- Q2. What does this print? (code)
- Q3. What does compare-and-set (CAS) do?
- Q4. Which call counts a word in a ConcurrentHashMap safely from many threads?
- Q5. What does this print? (code)
- Q6. A CountDownLatch is created with count 3. When does await() return?
- Q7. You want at most 3 threads to use the database at the same time. Which tool fits?
- Q8. What does this print? (code)
- Q9. In a CompletableFuture chain, a stage throws an exception. What happens to the next thenApply?
- Q10. What is the main advantage of ConcurrentHashMap over a HashMap wrapped in synchronized blocks?