Ok, final update for the time being: it was in fact the case that whenever I was waiting on the stdin readln() or UDP recv() mentioned above, listenTCP couldn't accept connections and Mongo operations wouldn't go through.

For the time being I'm working around it by not using threads or runTask, and instead ensuring that both the readln() and UDP recv() will return at least once a second, and sleeping afterwards to give listenTCP a chance. (If there's a way to set a timeout for either of those functions, or make them non-blocking, please someone let me know! I couldn't find anything.)

Sönke, if the problem wasn't something silly in my code, and the information I posted above makes it seem like something is broken that you want to look into, I'll be happy to help however I can.