hi there,
I think I've found another problem with 0.8.3 and threading.
I attached a test class that reproduces the problem, but basically:
- I create a variable in one thread A (ie. Ruby code "a =1")
- I start another thread B, then try to access the variable on it (Ruby
code "p a"),
and this will complain about an unknown variable
- etc.
Ie. Ruby variables behave like threadlocal variables.
I'm running a selfcompiled version of CVS HEAD from yesterday (13th
April), although
I don't know how uptodate that is (considering SFs slow anon CVS).
Can someone reproduce this or is this fixed and the code is just not
committed to CVS?
Thanks,
murphee
--
Blog @ http://jroller.com/page/murphee
Maintainer of EclipseShell @ http://eclipse-shell.sourceforge.net/
import org.jruby.IRuby;
import org.jruby.Ruby;
public class TestVariableCreation {
public static IRuby r;
public static Object object;
public static void main(String[] args) {
r = Ruby.getDefaultInstance();
// define new method
r.evalScript("def foo\n \"Hello\" \n end");
r.evalScript("a = 1\n");
r.evalScript("p a");
// will run on non main thread
Runnable run = new Runnable(){
public void run(){
try {
object = r.evalScript("p a");
} catch(Exception ex){
System.out.println(ex);
}
object = r.evalScript("a=2");
object = r.evalScript("p a");
}
};
Thread n = new Thread(run);
System.out.println("--------------- Calling Foo on Non-Main Thread --------------");
n.start();
try {
n.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
}
// Now from the same thread
System.out.println("----------- Calling from Thread ---------------");
object = r.evalScript("p a");
}
}