Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!labrea!polya!ali From: ali@polya.Stanford.EDU (Ali T. Ozer) Newsgroups: comp.sys.next Subject: Re: How do you use threads from an objective-c program? Message-ID: <8247@polya.Stanford.EDU> Date: 7 Apr 89 15:41:36 GMT References: <387@hydra.gatech.EDU> Sender: Ali T. Ozer Reply-To: aozer@NeXT.com (Ali Ozer) Organization: . Lines: 23 In article <387@hydra.gatech.EDU> roy@prism.gatech.EDU (Roy Mongiovi) writes: >Ahah! I thought. This sounds like a job for threads. So I hacked >up the code so that the main drawing loop is a separate function >and ran it in another thread. Imagine my surprise when the window >server complained that the client connection had closed prematurely >and then bombed out. Yes, it is a job for threads, but no, you cannot do what you tried to do. Reason? The window server currently cannot talk to two seperate threads at the same time within one context. One solution is to have the thread do the compute-intensive stuff and have the main thread do all the PostScript communication. Another solution might be to create another context; but I haven't had the chance to explore that yet and am not sure about the details right now... In the meantime, if you wish to do tons of drawing but you also want to be able to use your menus, buttons, etc at the same time, look at timed entries. With a timed entry, a function can be called repeatedly every so often. Because the timed entries act like events, user events also fire and can be serviced between calls to the timed entry function. Ali Ozer, NeXT Developer Support