From: Praful Date: 2008-03-02T02:04:56+09:00 Subject: Re: Threads in RubyCocoa apps On Feb 28, 9:32 pm, Alex Fenton wrote: > Praful wrote: > > I'm writing a GUI that starts a worker thread using Thread.start. The > > Cocoa docs say that you should update the GUI using the main thread > > only. However, the examples that ship with Leopard, eg SimpleApp, have > > a thread that update the GUI from the thread without passing it to the > > main thread. > > When the Cocoa (Objective C) docs talk about threads, I would assume > they're referring to operating system threads. Ruby 1.8 threads are not > operating system threads - they're implemented within the interpreter. > Since all Ruby 1.8 threads are within the same operating system thread, > so it's usually safe to call GUI code in any thread. > > A little bit of care can be needed, because ruby's thread scheduler can > potentially switch context in a place where it shouldn't. For example, > I've seen Carbon errors on OS X in wxRuby where it appears execution has > switched inside an operation like drawing to a device context. > > alex Many thanks Alex.