diff --git a/core/src/main/java/org/jruby/RubyThreadGroup.java b/core/src/main/java/org/jruby/RubyThreadGroup.java index 652c4939b83..9518e013d41 100644 --- a/core/src/main/java/org/jruby/RubyThreadGroup.java +++ b/core/src/main/java/org/jruby/RubyThreadGroup.java @@ -95,12 +95,11 @@ public IRubyObject add(ThreadContext context, IRubyObject rubyThread, Block bloc } } - // always set group when added explicitly - thread.setThreadGroup(this); - // we only add live threads if (thread.alive_p(context).isTrue()) { addDirectly(thread); + } else { + thread.setThreadGroup(this); } return this;