eliminated volatile

This commit is contained in:
Bruce Eckel 2017-01-02 14:20:31 -08:00
parent 8c4b4e7896
commit 620703ef6f

View File

@ -7,13 +7,11 @@ import java.util.function.*;
import onjava.Timer;
public class Summing {
static volatile long result;
static void timeTest(String id, long checkValue,
LongSupplier operation) {
System.out.print(id + ": ");
Timer timer = new Timer();
// Prevent optimization:
result = operation.getAsLong();
long result = operation.getAsLong();
if(result == checkValue)
System.out.println(timer.duration() + "ms");
else