Skip to content
KALANBLON
Show contents

Chapter 7 of 7 · 10 min

Quiz: concurrency and project

Executors, atomics, CompletableFuture and virtual threads: let's check that your parallel code is fast and correct. You need 70% correct answers.

Quiz

6 questions · pass mark: 70%

  1. 1.Four threads each run counter++ 100,000 times on a shared int. What is printed?

    One answer

  2. 2.Complete to increment a shared counter without a data race.

    Complete the code

    AtomicInteger counter = new AtomicInteger();
    counter.____();
  3. 3.What does closing an ExecutorService with try-with-resources do?

    One answer

  4. 4.When do virtual threads bring the most?

    One answer

  5. 5.Which statements about CompletableFuture are true? (several answers)

    Several answers possible

  6. 6.In the orders project, why are the events applied on a single thread?

    One answer

Your progress is saved on this device. Create a free account to keep your progress on all your devices.