Hi Guan,
Why do you need thread safety, are you intending to write to the NetCDF file or
mutate the Variable objects in some way? Or are you worried that two
simultaneous reads from the same file in different threads might interfere with
each other? I'm pretty sure this latter kind of collision doesn't occur, so I
assume that the code is thread-safe from this point of view.
Hope this helps,
Jon
On 18 Apr 2011, at 22:50, "Guan Wang" <gwang@xxxxxxx<mailto:gwang@xxxxxxx>>
wrote:
Hi,
I am a newbie for NetCDF-Java library. I try to use this library directly in the
Servlet environment to access THREDDS nc aggregation datasets. Here are some
codes I put together:
----------------------------------------------------------------------------
-
Set<Enhance> DATASET_ENHANCEMENTS =EnumSet.of(Enhance.ScaleMissingDefer);
NetcdfDataset nc=NetcdfDataset.openDataset(
"MY_THREDDS_URL",
DATASET_ENHANCEMENTS,
-1, null,
null
);
List<Variable> l=nc.getVariables();
Variable vv=null;
for(Variable v:l)
{
if(v.getName().equals("time"))
{
vv=v;
break;
}
}
Array arr;
List<Range> ranges=new ArrayList<Range>();
try {
r = new Range(8759,8759);
ranges.add(r);
arr=vv.read(ranges);
} catch (InvalidRangeException e) {
e.printStackTrace();
}
nc.close();
My question is:
If all variables are defined locally, are these methods guaranteed to be
thread-safe?
If my approach is not appropriate, is there a preferred suite of
classes/methods that I should look into?
Thanks,
Guan
_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx<mailto:netcdf-java@xxxxxxxxxxxxxxxx>
For list information or to unsubscribe, visit:
http://www.unidata.ucar.edu/mailing_lists/