Fixed issue: #71

This commit is contained in:
UnlegitDqrk
2026-03-02 14:22:54 +01:00
parent 9cb10a390f
commit 39ff4f204d
90 changed files with 324 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import org.luaj.vm2.Globals;
import org.luaj.vm2.libs.jse.JsePlatform;
import org.luaj.vm2.libs.jse.LuaScheduler;
public class SampleLuaScheduler {
public static void main(String[] args) throws Exception {
Globals globals = JsePlatform.standardGlobals();
LuaScheduler scheduler = new LuaScheduler(globals);
globals.load(
"spawn(function()\n" +
" print('task1 start')\n" +
" wait(250)\n" +
" print('task1 after wait')\n" +
"end)\n" +
"spawn(function()\n" +
" print('task2 start')\n" +
" yield()\n" +
" print('task2 next tick')\n" +
"end)\n",
"sample_scheduler.lua"
).call();
while (scheduler.hasPendingTasks()) {
if (scheduler.runReadyTasks() == 0) {
Thread.sleep(scheduler.millisUntilNextTask());
}
}
}
}