Re: Swing/AWT concurrency

Brian S O'Neill via Concurrency-interest <[email protected]> Tue, 10 Aug 2021 19:17:54 -0700
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <[email protected]>
On 2021-08-10 05:23 PM, Gregg Wonderly via Concurrency-interest wrote:
>
> Across thread sharing is a paramount point of Java AWT/Swing fm development.
>

And this is where AWT got it wrong. There was never any reason to design 
a GUI framework that didn't behave like a good-ol' single-threaded event 
loop. The thread that starts the app should be "main", and this is the 
same thread that should be processing events. Background tasks can be 
performed by separate threads, but this can be safely integrated such 
that users don't have to deal with race conditions.

If you look back at Java in 1995, you'll see that it got threading wrong 
pretty much everywhere. Many of the demo applets want to show off Java 
threads, and they issue things like stop/suspend/resume and do all sorts 
of unsafe state sharing.

Most of these mistakes have been fixed -- APIs have been deprecated, 
replacements created, better frameworks exist now, there's a proper 
memory model specification, and all of the old demos are gone. And yet 
the AWT still exists. Back in 1995 we called it the "Awkward Window 
Toolkit". It never made much sense, but somehow it needed to show that 
threads were useful, even for toy applets. At the time, that's all Java 
was -- an applet demo system.

I'm not a radio enthusiast, but I assume that like any hobby, there's 
different levels. I can jump into the hobby with requiring an EE degree, 
but I'll want that to achieve expert level. If I had to start off by 
designing and building my own radio, that's not a lot of fun.

Is your argument that Java is like this? Start with a pile of parts and 
design your own radio? If I want to write a GUI app, I shouldn't have to 
write my own framework for doing this. I'd like to use one that's 
already built-in and works just fine. With Java, such a thing doesn't 
exist. The starter radio kit has broken insulation and frequently 
electrocutes you.

Java has never been very popular on the desktop, or in the browser, and 
it never will be until the mistakes of 1995 are wiped clean. It needs a 
completely new GUI framework, modeled after something that actually 
works. Until that happens, it's completely inappropriate to expose new 
users to writing GUI apps in Java.

I've not looked at JavaFX. Is it a rewrite, or is it layered on top of 
AWT just like Swing? Is it single-threaded from the user's perspective, 
or does it suffer all the same problems by trying to be multi-threaded?