Skip to content

请问如何正确实现sleep延时效果 #35

@Gnakkk

Description

@Gnakkk
JavaFunction sleep = new JavaFunction(L) {
                @Override
                public int execute() throws LuaException {
                    int time = L.toInteger(2);
                    try {
                        Thread.sleep(time);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    return 1; 
                }
            };
            sleep.register("sleep");

例子:
print(1)
sleep(6000)
print(2)

问题:sleep()和print等函数一起使用时,延时6秒后才同时打印出1和2(而不是先打1过6秒后打2)
有什么好方法吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions