HADOOP-10852 Fix thread safety issues in NetgroupCache. (Benoy Antony)

(cherry picked from commit a095622f36c5e9fff3ec02b14b800038a81f6286)