Xref: utzoo comp.sys.next:14752 comp.os.mach:872 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!rosie!sstreep From: sstreep@next.com (Sam Streeper) Newsgroups: comp.sys.next,comp.os.mach Subject: Re: NXPing() in a thread Message-ID: <414@rosie.NeXT.COM> Date: 26 Mar 91 19:41:30 GMT References: <00946246.F502A0C0@uno.edu> <19044@milton.u.washington.edu> Sender: news@NeXT.COM Followup-To: comp.sys.next Organization: Next Computer, Inc. Lines: 37 Nntp-Posting-Host: elvis.next.com In article <19044@milton.u.washington.edu> wiml@milton.u.washington.edu (William Lewis) writes: >In article <00946246.F502A0C0@uno.edu> jrscs@uno.edu writes: >> I have a question on the use of NXPing() in a detached thread. The >>detached thread processes some sound data while the "main" thread handles >>the user interface. NXPing() works fine inside the main thread but it >>hangs my NeXT if it call it inside the method for which the thread was >>launched. > > I can't imagine how it would hang the whole NeXT, but I can see how >it could hang your application without much trouble. The trouble Remember every app is a client of the Window Server. If you violate the window server by entering from multiple threads, everybody loses. >multi-threaded environment. So when you call NXPing() in a subsidiary >thread, the main thread is probably sitting in DPSGetEvent() (assuming >it's a normal Appkit-using application), and both threads attempt to >interact with the window server simultaneously, with undesirable results. Exactly. >As far as I >know, the only way to do this is to send a Mach message to a port >registered via DPSAddPort(), which will wake up the main thread; the >handler on that port can then NXPing() or do other arbitrary This is a good solution. For a code example similar to this, see /NextDeveloper/Examples/SortingInAction -sam Opinions are not those of my employer. They're not even mine. They're probably wrong besides. How did they get in here, anyway? -- Opinions are not those of my employer. They're not even mine. They're probably wrong besides. How did they get in here, anyway?