![]() |
|
|
Issue Type:
|
Bug
|
Affects Versions:
|
JRuby 1.7.0.pre1, JRuby 1.6.7 |
Assignee:
|
Unassigned |
Components:
|
Core Classes/Modules |
Created:
|
09/Jul/12 9:39 AM
|
Description:
|
The following code should produce:
$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
$ ruby /tmp/thread_test.rb
10000
10000
10000
10000
10000
But, instead produces something like the following with JRuby:
$ ruby --version
jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (OpenJDK 64-Bit Server VM 1.7.0_03-icedtea) [linux-amd64-java]
$ ruby --1.9 /tmp/thread_test.rb
22058
22404
21514
22573
19653
JRuby's implementation doesn't appear to isolate @val (per thread instance) like Ruby's does. The source:
require 'thread'
PUTS_MUTEX = Mutex.new
def s_puts str
PUTS_MUTEX.synchronize { puts str }
end
@started = false
threads = (0...5).collect do
Thread.new do
@val = 0
until @started; end #cheesy, but avoids a thread completing before another starts
10000.times { @val += 1 }
s_puts @val
end
end
@started = true
threads.each { |thread| thread.join }
|
Project:
|
JRuby
|
Priority:
|
Major
|
Reporter:
|
Brian Ericson
|
|
|
|
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
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