Skip to content

请问应该怎么使用多线程呢? #32

Open
@qq292

Description

@qq292

我这样写,并没有用。。

public class FunctionThread extends JavaFunction {
    /**
     * Constructor that receives a LuaState.
     *
     * @param L LuaState object associated with this JavaFunction object
     */
    private LuaObject luaFunc;
    private LuaState luaThread;
    public FunctionThread(LuaState L) {
        super(L);
    }

    @Override
    public int execute() throws LuaException {
        if (L.isFunction(2)) {
            luaFunc = L.getLuaObject(2); 
            luaThread= L.newThread();
            luaThread.pushObjectValue(luaFunc);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    int p = luaThread.pcall(0,0,0);
                    if(p!=0){
                        Log.i("99999999999",luaThread.toString(-1));
                    }

                }
            }).start();
        }
        return 0;
    }
    public void register() {
        try {
            register("threads");
        } catch (LuaException e) {
            e.printStackTrace();
        }
    }
}

任何人都可以回答这个问题!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions