diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index <HASH>..<HASH> 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -835,7 +835,11 @@ module ActiveRecord
         end
 
         def with_new_connections_blocked
-          synchronize do
+          if defined?(JRUBY_VERSION)
+            synchronize do
+              @threads_blocking_new_connections += 1
+            end
+          else
             @threads_blocking_new_connections += 1
           end
Ivar += in MRI is thread safe