Home » Tip Bank » Java
  • Comment on this Article
Language: Java
Expertise: Intermediate
May 11, 2020

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Watch

How to Increment Integers

The following example increments integers from 1-1000000 via LongAdder:

public class AtomicAdder implements Runnable {

    public static LongAdder count = new LongAdder();
    
    @Override
    public void run() {
        count.add(1);
    }

    public long getCount() {
        return count.sum();
    }        
} 
Octavia Anghel
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
codeschool.com
activatejavascript.org