Skip to content

TimerTask is starting a non-daemon thread #839

Closed
@fzakaria

Description

@fzakaria

I have a small reproduction example:

  def test_timer_task
    task = Concurrent::TimerTask.new(execution_interval: 1) do
      puts "Here"
    end
    task.execute
  end

The threads started by TimerTask should be daemons however the JVM does not shutdown.
There seems to be some other concurrent-ruby thread which is not a daemon

The problem is that at the end of the test, the JVM remains active and does not shutdown.

(The following is from jstack)

"pool-6-thread-1" #61 prio=5 os_prio=31 tid=0x00007fe599823800 nid=0xb103 in Object.wait() [0x0000700013a56000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Object.java:460)
        at org.jruby.RubyThread$SleepTask.run(RubyThread.java:1410)
        - locked <0x000000076e124a08> (a com.concurrent_ruby.ext.SynchronizationLibrary$JRubyLockableObject)
        at org.jruby.RubyThread.executeBlockingTask(RubyThread.java:1463)
        at org.jruby.RubyThread.wait_timeout(RubyThread.java:1933)
        at com.concurrent_ruby.ext.SynchronizationLibrary$JRubyLockableObject.nsWait(SynchronizationLibrary.java:254)
        at com.concurrent_ruby.ext.SynchronizationLibrary$JRubyLockableObject$INVOKER$i$0$1$nsWait_DBG.call(SynchronizationLibrary$JRubyLockableObject$INVOKER$i$0$1$nsWait_DBG.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:796)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:202)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:153)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:315)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:159)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:127)
        at org.jruby.runtime.InterpretedIRBlockBody.yieldDirect(InterpretedIRBlockBody.java:109)
        at org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:80)
        at org.jruby.runtime.Block.yieldSpecific(Block.java:134)
        at org.jruby.RubyKernel.loop(RubyKernel.java:1316)
        at org.jruby.RubyKernel$INVOKER$s$0$0$loop_DBG.call(RubyKernel$INVOKER$s$0$0$loop_DBG.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroBlock.call(JavaMethod.java:536)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:77)
        at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:84)
        at org.jruby.ir.instructions.CallBase.interpret(CallBase.java:429)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:360)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:159)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:84)
        at org.jruby.internal.runtime.methods.InterpretedIRMethod.INTERPRET_METHOD(InterpretedIRMethod.java:182)
        at org.jruby.internal.runtime.methods.InterpretedIRMethod.call(InterpretedIRMethod.java:165)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
        at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:170)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:336)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:159)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:127)
        at org.jruby.runtime.InterpretedIRBlockBody.yieldDirect(InterpretedIRBlockBody.java:109)
        at org.jruby.runtime.BlockBody.yield(BlockBody.java:114)
        at org.jruby.runtime.Block.yield(Block.java:165)
        at com.concurrent_ruby.ext.SynchronizationLibrary$JRubyLockableObject.rubySynchronize(SynchronizationLibrary.java:232)
        - locked <0x000000076e124a08> (a com.concurrent_ruby.ext.SynchronizationLibrary$JRubyLockableObject)
        at com.concurrent_ruby.ext.SynchronizationLibrary$JRubyLockableObject$INVOKER$i$0$0$rubySynchronize_DBG.call(SynchronizationLibrary$JRubyLockableObject$INVOKER$i$0$0$rubySynchronize_DBG.gen)
* Operating system:               mac
* Ruby implementation:             jruby 9.1.17.0 (2.3.3)
* `concurrent-ruby` version:       1.1.5
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used:     no

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions