* fix: avoid iterating over a changing table in `run_threads`
This is done to avoid iterating over a table that can change in the meantime.
More precisely the issue appears if a thread is removed from the table, we yield early from `run_threads` because we reached the end of the frame, and a new thread is added before the next iteration.
For example:
```lua
local lost_time = false
core.add_thread(function()
-- force early yield
local t0 = system.get_time()
while system.get_time() - t0 < .1 do end
lost_time = true
end, "a")
local step = core.step
function core.step()
if lost_time then
-- add a new thread while run_threads hasn't finished iterating
core.add_thread(function()end, "a1")
lost_time = false
end
return step()
end
```
would crash with `invalid key to 'next'`.
* fix: only run coroutine if it wasn't removed
* fix: don't handle `core.threads` table as an array
This caused some entries to be skipped or even removed erroneously.