lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello!

Here is another question concerning LuaJava:

I'm currently checking inhowfar LuaJava is "thread-safe" (it
must be - otherwise it would be impossible to script graphi-
cal user interfaces).

For that reason,  I instantiate  a Java Thread object  which
uses a run function from a Lua table (by means of a "helper"
class written in Java which solves some problems arising due
to the way LuaJava tries to handle polymorphism).

Everything works fine (e.g., I can invoke the "run" function
myself)  until I try to "start"  the thread - then I get the
following output

  error: attempt to index a string value
  error: unable to recover; exiting

For illustration purposes,  here is the relevant part  of my
source code:

LuaJava_11.java:
  public class LuaJava_11 {
    public static Thread newThread (Runnable LuaWrapper) {
      return new Thread(LuaWrapper);
    };
  };

LuaJava_11.lua:
  HelperClass = javaBindClass("LuaJava_11");

  function startThread
    local LuaThread = {
      run = function (self)
        print("Hello!");
      end
    };

    local JavaThrad = HelperClass:newThread(LuaThread);
    JavaThread:start();
  end;

  startThread();

I've tried lots of variants of this code - but without any
success!

Does anybody have any idea?

Thanks in advance for your help!

Andreas Rozek         Phone:  ++49 (7031) 222305
Bunsenstraße 82       Fax:    -
D-71032 Böblingen     EMail:  A.Rozek@GMX.De
Germany               URL:    http://www.Andreas-Rozek.de