On consideration, I recommend Dave's solution:
RealType X;
try {
X = new RealType("X",null,null);
} catch (TypeException e) {
X = RealType.getRealTypeByName("X");
}
because its thread safe. My initial solution:
RealType X = RealType.getRealTypeByName("X");
if (X == null) X = new RealType("X",null,null);
is not, because another thread can construct a
'RealType("X",null,null)' between my calls to
'getRealTypeByName' and 'new RealType'.
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706
whibbard@xxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html
"kill cross-platform Java by growing the polluted Java market"
- from an internal Microsoft planning document