New threads are not immediately "visible" to the Thread.list method
-------------------------------------------------------------------

                 Key: JRUBY-879
                 URL: http://jira.codehaus.org/browse/JRUBY-879
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.0.0
         Environment: Linux, recent JRuby trunk build
            Reporter: Martin Krauskopf


Try the following script:

{code}
a = Thread.new { Thread.current["name"] = "A"; Thread.stop }
b = Thread.new { Thread.current[:name]  = "B"; Thread.stop }
c = Thread.new { Thread.current["name"] = "C"; Thread.stop }
#sleep 0.1
puts "c thread #{c.status}"
puts "b thread #{b.status}"
puts "a thread #{a.status}"
puts "main: #{Thread.main.status}"
Thread.list.each {|x| puts "#{x.inspect}: #{x[:name]}" }
puts "c thread #{c.status}"
puts "b thread #{b.status}"
puts "a thread #{a.status}"
puts "main: #{Thread.main.status}"
{code}

With JRuby I'm getting following "strange" output:

{code}
c thread run
b thread sleep
a thread sleep
main: run
#<Thread:0x1428ea sleep>: A
#<Thread:0x154864a sleep>: B
#<Thread:0x1d2068d run>: 
c thread run
b thread sleep
a thread sleep
main: run
{code}

The _C_ thread says that it is running however is not listed with the {{list}} 
function. With CRuby it works as expected. If {{sleep 0.1}} line is uncommented 
everything starts to work with JRuby as well. Probably some implementation 
detail. Might be without the real impact. Leaving _Priority_ up to the owner.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to