NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

Re: [netcdf-java] Variable object thread safe?


Jon Blower wrote:
> So presumably if you use the NetCDF file cache, you have to do the
> synchronization yourself, since you might be transparently sharing
> file handles?  That's an aspect of the cache that hadn't occurred to
> me before...

The way that the cache is designed to work is that you get back a NetcdfFile 
object, which should then used only in a single thread so you dont need 
synchronization ("thread-confinement"), such as to answer a single request in a 
server. Until you release that NetcdfFile object, no one else can get it from 
the cache. If another request is made for that same NetcdfFile while its 
locked, a new NetcdfFile is opened. 

And of course, the cache itself is thread-safe. So if you use it properly, you 
never have to do synchronization yourself.