• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MultiThreading should I or shouldn't I?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MultiThreading should I or shouldn't I?


  • Subject: Re: MultiThreading should I or shouldn't I?
  • From: Nathan Day <email@hidden>
  • Date: Wed, 26 Jun 2002 12:50:13 +0930

There are three reasons to use multithreading, to take advantage of multiple processors, to make solving some particular problem easier (eg a game where multiple things have to occur seemingly simultaneously) or so user interaction isn't held up. Threads will not make your code faster unless you have multiple processors, in fact the extra overhead can slow things down. If you are not sure if multiple thread will help your program try writing it without threads first but keeping in mind you might want to add threads later. Creating threads on Mac OS X is as easy as

[NSThread detachNewThreadSelector:@selector(startMethod:) toTarget:self withObject:nil];

the difficulty lie in trying to control accesses to variable common to all thread as well as resources, this is a problem for all multithread programming. One problem in Mac OS X is there are part of the App Kit, to do with user interaction, that can only occur in the main thread, you have a thread that wants to put up a dialog window to notify the user of some thing and things can get complicated. The only book I have on thread programming is "Programming with Threads, Kleiman, Shah and Smaalders", It is a good book, with lots of references to POSIX, but then I can't tell you how it compares to any other title.

On Tuesday, June 25, 2002, at 04:33 AM, Ken Tozier wrote:

MultiThreading sounds catchy and cool, but I have absolutely no experience with it and don't know the pros and cons. I read the meager info at Apple and don't know if it would be a good way to go for my app. I all seems very complex but that may just be due to my complete lack of experience with multithreading.

Say I want to have realtime streams open to several remote sources of weather data. Would it be better to have a single bottleneck that the remote sites log on to or give the remote sources the ability to connect on their own each spawning a new thread? Could a centralized application query these threads easily for info? How would it know who's connected at any given time? Which would be faster?

I'll no doubt have loads more questions but I'll leave it at that for now.

Thanks

Ken Tozier

P.S. is multithreading on OS X complex enough to justify picking up one of the tomes on the subject? Any recommended titles?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >MultiThreading should I or shouldn't I? (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: NSTableView philosophy question.. (MVC Pattern) where to put the dataSource delegate?
  • Next by Date: NSMutableArray: where is addObjectIfAbsent:?
  • Previous by thread: MultiThreading should I or shouldn't I?
  • Next by thread: C types and memory management
  • Index(es):
    • Date
    • Thread