newthread and ref should be the same lua_State