Fix wrong thread id when resuming after interrupt.

Who knows what kind of havoc this was causing.
Merge pull request #2614 from unknownbrackets/scheduling

Fix wrong thread id when resuming after interrupt.