use the 'Double-Checked Locking using Volatile' idiom, for #696
parent
f3410c517c
commit
8d82bd8ac0
|
@ -53,7 +53,7 @@ public class MagicManaCost {
|
|||
private final int converted;
|
||||
private final int XCount;
|
||||
private final List<MagicCostManaType> order = new ArrayList<>();
|
||||
private MagicBuilderManaCost builderCost;
|
||||
private volatile MagicBuilderManaCost builderCost;
|
||||
private List<MagicIcon> icons;
|
||||
|
||||
private MagicManaCost(final String aCostText) {
|
||||
|
@ -335,7 +335,11 @@ public class MagicManaCost {
|
|||
|
||||
public MagicBuilderManaCost getBuilderCost() {
|
||||
if (builderCost == null) {
|
||||
builderCost = new MagicBuilderManaCost(this);
|
||||
synchronized (this) {
|
||||
if (builderCost == null) {
|
||||
builderCost = new MagicBuilderManaCost(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return builderCost;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue