[Openmcl-devel] NSApplication run method does not seem to work quite right

Willem Rein Oudshoorn woudshoo at xs4all.nl
Sun Mar 9 00:14:51 PST 2014

Gary Byers <gb at clozure.com> writes:

> In order to communicate with the window system, Cocoa GUI code needs to run
> on the initial thread.
> You seem to think that this is only true of some code (the event loop) and
> not other code (the code that creaetes a window).  You'll often find that
> code that tries to do GUI things on some other thread sort-of-kind-of works
> (it's as if the thread that created the window couldn't properly communicate
> with the window system.)

Yes you are right.  If you put the creation of the NSApplication class
on the initial thread it works better.

I was put on the wrong foot because the statement about Cocoa and
Multithreading seem to imply that:

   unless otherwise stated, you can use Cocoa from multiple threads if
   you use only one thread at the time.

(Paraphrasing mine).

Unfortunately it did not jump out at me, from reading the Apple
documentation, that I should create Cocoa objects in the initial thread.

Well, lesson learned, and thank you for pointing this out.

Wim Oudshoorn.

More information about the Openmcl-devel mailing list