implement command loop in lua, move to separate JVM thread