3 ms·
Uh-huh. Typically GUI work is instantiated with the GUI toolkit on the call stack. It calls foo.onClick(), etc. Now, if one particular onClick starts long-runn
by Arnt 11y ago
Uh-huh.
Typically GUI work is instantiated with the GUI toolkit on the call stack. It calls foo.onClick(), etc. Now, if one particular onClick starts long-running task, then there are three possible designs:
Either that particular onClick() starts a worker thread and returns before the worker is done.
Or the GUI toolkit delivers the onClick() in a thread of its own, e.g. from a pool of workers.
Or everything is done in one thread, and the UI blocks.
The last one seems sucky, but the insidiously sucky one is the one in the middle. That's where every user's implementation of onFocusOut() must take care to lock because all of bar.onFocusOut(), foo.onFocusIn(), foo.onMouseUp() and foo.onClick() are called concurrently in four different worker threads. The tail wags the dog.