Event-architecture & concurrency

Is there a conceptual difference between concurrent GUI programming and other types of concurrent programming?

Sometime a GUI pops up modal dialog (Ex. Save file as...) that blocks access to the rest of the user interface until that dialog is dismissed.

Other times clicking a button may turn the mouse cursor into an hourglass and block mouse/keyboard input until the button action completes (this is done so the user cannot repeatedly click the button until the task completes).

Blocking the user from interacting with parts of the user interface appear to be similar to the idea of critical sections. Normally critical sections allow one thread at a time to execute them. In the GUI examples, we want the sections to only allow events dispatched from any source but exclude events from the "user" source.

This is usually done by pushing/popping event queues (in the case of the modal dialog), or discarding events (in the case of hourglass/input blocking).

Just curious if anyone has thoughts on how things like locks, barriers, futures, exchangers, etc, work at a macroscopic level in the GUI domain.

[1141 byte] By [jvaudrya] at [2007-11-26 20:51:34]
# 1

GUIs tend to be fundamentally single-threaded event-driven systems. The basic idea is that the state of the GUI should transition based on an underlying state-machine model. Threading comes into it in two main ways:

1. Interacting with the "data" side of components that also have a GUI side

2. Spawning threads to perform long running tasks in response to some event.

For #1 Swing enforces the single-thread rule which basically requires everything to occur in the event-thread.

Normal synchronization tools can be used to interact between event thread and threads for #2 but with great care. You should never block the event thread as it kills the GUI responsiveness. "waiting" in a GUI can be achieved by disabling events that would otherwise cause the actions you want to delay, until the required action sends an event to say it has happened.

davidholmesa at 2007-7-10 2:16:42 > top of Java-index,Core,Core APIs...