Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining a top-level/main run method overrides Runnable.run #2542

Closed
ajitgeorge opened this issue Jan 30, 2015 · 2 comments
Closed

Defining a top-level/main run method overrides Runnable.run #2542

ajitgeorge opened this issue Jan 30, 2015 · 2 comments

Comments

@ajitgeorge
Copy link

@ajitgeorge ajitgeorge commented Jan 30, 2015

at least in interop with java.lang.Thread, as the following code demonstrates:

def run 
  puts 'in def run'
  # super # invoking super allows the thread blocks to run 
end 

latch = java.util.concurrent.CountDownLatch.new(2)
t1 = java.lang.Thread.new { puts 'executing t1'; latch.count_down }
t2 = java.lang.Thread.new { puts 'executing t2'; latch.count_down }

t1.start
t2.start

success = latch.await(1, java.util.concurrent.TimeUnit::SECONDS) 
puts success ? 'succeeded' : 'failed'
exit (success ? 0 : 1)

I'm seeing this behavior on all JRuby 1.7 versions up to 1.7.18 as well as
1.6.8, using Oracle JDK 1.7.0_72.

The problem doesn't occur with Ruby threads, probably because no implicit Runnable is created.

Note that the test-unit gem defines run in such a way that only the first thread block never executes.

A workaround is to undef run right after requiring test-unit.

@MSNexploder
Copy link
Contributor

@MSNexploder MSNexploder commented Jan 31, 2015

Same issue on master (7951249)

@kares
Copy link
Member

@kares kares commented May 23, 2017

its no longer the case with JRuby 9K due generate interface methods being bound directly

@kares kares closed this as completed May 23, 2017
@kares kares added this to the Invalid or Duplicate milestone May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants