Which tool is appropriate for lock-free integer counters?
Practice this question from Quiz: Java Concurrency, with options and an explanation.
Question
Which tool is appropriate for lock-free integer counters?
Option A — Correct answer
AtomicInteger
AtomicInteger provides atomic operations such as incrementAndGet.
Option B
StringBuilder
Option C
Scanner
Option D
HashSet