javamultithreadingconcurrencyinterlocked

What's Java's equivalent of .Net's Interlocked class?


How do I modify an int atomically and thread-safely in Java?

Atomically increment, test & set, etc...?


Solution

  • Use AtomicInteger.