Multi-threaded GUI

Russel Winder russel at winder.org.uk
Thu Jul 26 01:16:33 PDT 2012


On Wed, 2012-07-25 at 23:17 +0200, Kagamin wrote:
> On Wednesday, 25 July 2012 at 18:50:51 UTC, Simon wrote:
> > You have to be very, very careful with trying to do multi 
> > threading w/ windoze windows. Try doing a google search on it, 
> > and the advice is invariably: don't do multi threaded windows. 
> > Everybody including people famous for their in-depth window 
> > knowledge recommends a single thread UI with non-UI worker 
> > threads.
> 
> Hmm... AFAIK it's quite opposite: windows UI is the only UI that 
> works in multithreaded environment, it's just recommended to not 
> do it, because this feature is inconsistent with other UI 
> frameworks, so that you don't get used to wrong programming 
> technique.

I know essentially nothing of Windows, but quite a lot about
AWT/Swing/JavaFX/GroovyFX, GTK+2, GTK+3, PyGTK, PyGObject, PySide,
PyQt4, wxPython, and tkInter. As you say all of these use an
single-threaded event loop to manage all widgets. Fundamentally this is
because there is only one screen and one window manager, and all widgets
need to be manipulated relative to that. Using a single-threaded event
loop is the easiest way of avoid deadlock and livelock given that there
is a shared resource.

The same message has been learnt in Web servers where the multi-threaded
approach has given way to a single-threaded event loop approach.

So if Windows is really doing multi-threaded widget management, this
would be very interesting.  Where is the material that I can look at
that leads you to say that Windows is a multi-threaded UI.

As Simon mention, just because the UI is single-threaded doesn't mean
the application is. Exactly the opposite, good UI-based applications are
generally multi-threaded, it is just that there is only one thread
running the UI, all the others handle business logic.
-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120726/4d23f49d/attachment.pgp>


More information about the Digitalmars-d mailing list