package be.ac.vub.ir.multithreading; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import flanagan.math.Fmath; import be.ac.vub.ir.util.Chrono; public class Counting3s { int[] array; Counting3s(int length, int oneEveryX){ array = new int[length]; for(int i=0;i Speedup = "+Fmath.truncate((float) seqtime/partime, 2)); chrono.restart(); nbr = c.parCounting2(T); partime = chrono.stop(); System.out.println(" * Par 2 (boolean) : counted "+nbr+" 3s in "+chrono.toString()+" => Speedup = "+Fmath.truncate((float)seqtime/partime, 2)); chrono.restart(); nbr = c.parCounting3(T); partime = chrono.stop(); System.out.println(" * Par 3 (volatile) : counted "+nbr+" 3s in "+chrono.toString()+" => Speedup = "+Fmath.truncate((float)seqtime/partime, 2)); chrono.restart(); nbr = c.parCounting4(T); partime = chrono.stop(); System.out.println(" * Par 4 (sync method) : counted "+nbr+" 3s in "+chrono.toString()+" => Speedup = "+Fmath.truncate((float)seqtime/partime, 2)); chrono.restart(); nbr = c.parCounting5(T); partime = chrono.stop(); System.out.println(" * Par 5 (local ctr) : counted "+nbr+" 3s in "+chrono.toString()+" => Speedup = "+Fmath.truncate((float)seqtime/partime, 2)); chrono.restart(); nbr = c.parCounting5b(T); partime = chrono.stop(); System.out.println(" * Par 5b (padding) : counted "+nbr+" 3s in "+chrono.toString()+" => Speedup = "+Fmath.truncate((float)seqtime/partime, 2)); chrono.restart(); nbr = c.parCounting6(T); partime = chrono.stop(); System.out.println(" * Par 6 (atomic ctr) : counted "+nbr+" 3s in "+chrono.toString()+" => Speedup = "+Fmath.truncate((float)seqtime/partime, 2)); chrono.restart(); nbr = c.parCounting7(T); partime = chrono.stop(); System.out.println(" * Par 7 (atomic boolean): counted "+nbr+" 3s in "+chrono.toString()+" => Speedup = "+Fmath.truncate((float)seqtime/partime, 2)); chrono.restart(); nbr = c.parCounting8(T); partime = chrono.stop(); System.out.println(" * Par 8 (sync by main) : counted "+nbr+" 3s in "+chrono.toString()+" => Speedup = "+Fmath.truncate((float)seqtime/partime, 2)); } //======================== SEQUENTIAL COUNTING ===========================// int seqCounting(){ int count=0; for(int i=0;i