Re: visad.TypeException: ScalarType: name already used

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
 

  • 1998 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: