18 lines
483 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// concurrency/Fat.java
2015-06-15 17:47:35 -07:00
// Objects that are expensive to create.
public class Fat {
private volatile double d; // Prevent optimization
private static int counter = 0;
private final int id = counter++;
public Fat() {
// Expensive, interruptible operation:
for(int i = 1; i < 10000; i++) {
d += (Math.PI + Math.E) / (double)i;
}
}
public void operation() { System.out.println(this); }
@Override
public String toString() { return "Fat id: " + id; }
2015-09-07 11:44:36 -06:00
}