Merging event dispatch and toolkit threads

Dmitry Batrak dmitry.batrak at
Tue Aug 17 11:18:30 UTC 2021


Now that applets are deprecated for removal, what do you think about moving
towards the unification of event dispatch and toolkit threads in AWT? In my
understanding, thе separation between them was meaningful only for the
use case, and now it becomes a pure nuisance. E.g. accessibility support
implementation on macOS requires 'invokeAndWait' calls between two threads
both directions, and achieving this without deadlocks is quite tricky in
implementation. Also, windowing APIs on macOS and Windows are mostly
synchronous, and using them in a synchronous way (without passing execution
between threads) could potentially simplify focus subsystem implementation.
Benefits for X11/Wayland systems would be less significant, due to the
fundamentally asynchronous native APIs, but, even in those cases, having
outgoing requests sending and incoming events processing on the same thread
should make AWT code more reliable, as we'll have one less place for

Overall, having only one thread to deal with native windowing APIs, should
supporting and extending AWT simpler, and closer to native application
development. I think, some synchronization constructs would still need to be
present - to guard against the invocation of AWT methods from background
threads. But, at least for 'well-behaving' apps, the reasoning about
execution order
would be much easier.

Of course, for existing toolkit implementations (macOS/Windows/X11) the
transitioning will take some time and effort, but for the Wayland
implementation, to
be developed withing Wakefield project, the idea could be implemented from
AFAIU, with Wayland client API, we'll need to dispatch the incoming queue of
events explicitly anyway, and this dispatching can quite as well be done on

So, what do you think about the idea in general, and about starting to
realize it in
Wayland toolkit implementation?

Best regards,
Dmitry Batrak

More information about the client-libs-dev mailing list