jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-1239

Monitor synchronize hangs

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.0.0
  • Fix Version/s: JRuby 1.0.1
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
    ruby 1.8.5 (2007-06-07 rev 3841) [x86-jruby1.0]
  • Testcase included:
    yes

Description

This program (adapted from the pick-axe book) hangs in JRuby. It works without the "synchronize" block in sync_tick.

========================================================
#!/usr/bin/ruby

  1. multi-threading
    require 'monitor'

class Counter
include MonitorMixin
attr_reader :count, :scount
def initialize
@count = 0
@scount = 0
super
end
def tick
@count += 1
end
def sync_tick
synchronize do
@scount += 1
end
end
end

c = Counter.new
threads = []
2.times do
threads << Thread.new { 1_000.times { c.tick; c.sync_tick }}
end

threads.each { |t| t.join }

puts "Thread counter count=#{c.count} scount=#{c.scount}"

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. File
    thread.rb
    26/Jul/07 3:31 PM
    0.5 kB
    Doug Donohoe

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Doug Donohoe added a comment - 26/Jul/07 3:31 PM

Test file.

Show
Doug Donohoe added a comment - 26/Jul/07 3:31 PM Test file.
Hide
Permalink
Nicolas Modrzyk added a comment - 26/Jul/07 3:59 PM

Hi Doug,

Can't reproduce it with rev 4063. Could this have been possibly fixed ?
Can you try to update your code and see if it's still happening ?

Show
Nicolas Modrzyk added a comment - 26/Jul/07 3:59 PM Hi Doug, Can't reproduce it with rev 4063. Could this have been possibly fixed ? Can you try to update your code and see if it's still happening ?
Hide
Permalink
Doug Donohoe added a comment - 27/Jul/07 9:49 AM

I downloaded the trunk (4068) and this no longer happens. This can be closed as fixed.

Show
Doug Donohoe added a comment - 27/Jul/07 9:49 AM I downloaded the trunk (4068) and this no longer happens. This can be closed as fixed.
Hide
Permalink
Doug Donohoe added a comment - 27/Jul/07 9:50 AM

Fixed when tested in build 4068.

Show
Doug Donohoe added a comment - 27/Jul/07 9:50 AM Fixed when tested in build 4068.
Hide
Permalink
Timur Shipilov added a comment - 27/Dec/07 11:46 AM

I have the same problem with JRuby 1.0.3
C:\>jruby --version
ruby 1.8.5 (2007-12-15 rev 5200) [x86-jruby1.0.3]

OS: Windows XP

Show
Timur Shipilov added a comment - 27/Dec/07 11:46 AM I have the same problem with JRuby 1.0.3 C:\>jruby --version ruby 1.8.5 (2007-12-15 rev 5200) [x86-jruby1.0.3] OS: Windows XP

People

  • Assignee:
    Unassigned
    Reporter:
    Doug Donohoe
Vote (0)
Watch (2)

Dates

  • Created:
    26/Jul/07 3:30 PM
    Updated:
    27/Dec/07 11:46 AM
    Resolved:
    27/Jul/07 9:50 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.