eliminated volatile
This commit is contained in:
parent
8c4b4e7896
commit
620703ef6f
@ -7,13 +7,11 @@ import java.util.function.*;
|
|||||||
import onjava.Timer;
|
import onjava.Timer;
|
||||||
|
|
||||||
public class Summing {
|
public class Summing {
|
||||||
static volatile long result;
|
|
||||||
static void timeTest(String id, long checkValue,
|
static void timeTest(String id, long checkValue,
|
||||||
LongSupplier operation) {
|
LongSupplier operation) {
|
||||||
System.out.print(id + ": ");
|
System.out.print(id + ": ");
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
// Prevent optimization:
|
long result = operation.getAsLong();
|
||||||
result = operation.getAsLong();
|
|
||||||
if(result == checkValue)
|
if(result == checkValue)
|
||||||
System.out.println(timer.duration() + "ms");
|
System.out.println(timer.duration() + "ms");
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user