Subject: bug#34821: discard_input_tty does not discard pending input, resulting in garbage inserted into the buffer

From: Eli Zaretskii <[email-masked]>
Date: Sun, 07 Apr 2019 22:25:28 +0300

> From: Platon Pronko <[email-masked]>
> Date: Sun, 7 Apr 2019 22:06:23 +0300
> 
> > What do you mean by "run concurrently"?  Emacs is pretty much a single
> > threaded program, and there's only one Lisp thread running at any
> > given time, which will execute both calls.
> 
> My knowledge of Emacs internals is pretty thin indeed. But since adding sleep-for results in reordering of events, I thought that there are at least different threads that compete for execution (concurrent, maybe not parallel). Also I noticed that for example read_char() calls can block for quite a lot of time, while Lisp code continues to run. Perhaps there is one Lisp thread and some other background C threads?

No, there's just one thread.  The only other one I can think of is the
code of xterm itself.