Tweak interactive debug output
Fix intermittent crash in iothread.cpp

The wrong lock was being taken around the result queue, leading to the
occasional crash when processing interactive input. This didn't seem to
really affect normal day-to-day usage, but it did sometimes cause the
interactive tests to crash.

Fixes #1692.