Changes from Threadsafe

Hi,

The attached diff is what Numa did to his JRuby environment to make it Threadsafe Rails 4 compatible.

It should resolve the issue #12097.

Hope it helps,

Christopher