Lock when adding specs during Gem installation.

Related issue: https://github.com/rubygems/rubygems/issues/982. This should hopefully resolve threading problems that occur when using the current Bundler release to install Gems in parallel.