Lock when adding specs during Gem installation.

When installing Gems in a multi-threaded environment (e.g. Bundler) the
installer would try to run the following code:

    Gem::Specification.add_spec spec unless Gem::Specification.include? spec

This code is not thread-safe for two reasons:

1. Gem::Specification.add_spec modifies a global state
2. Gem::Specification.include? performs a read operation on a global state
   _while_ it might be modified

Working around this can be done in two ways:

1. Add locks to Gem::Specification where needed
2. Add locks in Gem::Installer where needed

The first option would require a lock around most class methods and possibly
other methods. As a result I've decided to, for now, go with option 2. Skimming
through the Installer class this appears to be the only place where a global
state is modified.

I've also removed the extra Gem::Specification.include? check in the installer.
The exact same procedure is also done in Gem::Specification.add_spec itself,
thus this is rather redundant.

The issue that led to this commit is #982 which contains more details about the
problem.
Merge pull request #1005 from YorickPeterse/master

Lock when adding specs during Gem installation.