[polyml] loadState and threads