Ruby.evalScriptlet() should respond to Thread.interrupt()
---------------------------------------------------------

                 Key: JRUBY-5562
                 URL: http://jira.codehaus.org/browse/JRUBY-5562
             Project: JRuby
          Issue Type: Improvement
    Affects Versions: JRuby 1.6RC2
         Environment: any
            Reporter: Benjamin Gudehus
            Assignee: Thomas E Enebo


The following example works, but it makes use of Thread.stop() which is 
deprecated.

When I call Thread.interrupt() the scriptled runs until end. I want to call 
Java methods inside the scriptlet and am afraid of some uncontrolled 
misbehaviour.

Is it possible to modify the evalX() methods, to respond to Thread.interrupt()?

{code:java}
import org.jruby.Ruby;

class JRubyStop {
    public static void main(String[] args) throws InterruptedException {
        final Ruby ruby = Ruby.newInstance();
        Thread thread = new Thread() {
            public void run() {
                String scriptlet = "for i in 0..10; puts i; sleep(1); end";
                try {
                    ruby.evalScriptlet(scriptlet);
                }
                catch (ThreadDeath ignore) {}
            }
        };
        thread.start();
        Thread.sleep(3000);
        System.out.println("interrupt!");
        //thread.interrupt();
        thread.stop();
        System.out.println("main finished");
    }
}

{code}

This issue is related to JRUBY-4135.


-- 
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