dcsimg
 

Submitted by: Octavia Anghel(octaviaanghel@gmail.com)

Monday May 11th 2020 by Octavia Anghel

Language: Java, Expertise: Intermediate - See an example of how to increment integers from 1-1000000 via LongAdder.

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();
    }        
} 
Home
Mobile Site | Full Site