• 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: Why multi-threading ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why multi-threading ?


  • Subject: Re: Why multi-threading ?
  • From: Chris Hanson <email@hidden>
  • Date: Tue, 27 May 2003 09:28:47 -0400

On Tuesday, May 27, 2003, at 07:23 AM, Dietrich Epp wrote:
One thread deals with the network, often blocked. One thread deals with everything else. This way I don't get disconnected when I fail to pong because the user is running a script, or saving a file, etc.

If this were single-threaded, I would have to do something like polling which is pretty damn inefficient. Instead, when data is available, the network thread unblocks and processes it without any intervention from the UI thread.

There's another way to do this as well: Events. If your network stack delivers events to your application code when things requiring its attention happen, you can be single-threaded and also not poll.

This is how Open Transport worked on the classical Mac OS. It's also the sort of API simulated using threads & blocking I/O behind the scenes by many Cocoa facilities (-[NSFileHandle readInBackgroundAndNotify] for example).

Multithreaded servers have scalability problems. That's why FreeBSD has kernel queues & events.

I'm not trying to suggest multithreading is never a good idea. In fact, I've used it quite a bit to good effect. But there are other mechanisms by which to achieve most of the same goals. (One that multithreading is necessary for is spreading the work of one process across multiple CPUs.)

-- Chris

--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Application Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: Why multi-threading ?
      • From: Dietrich Epp <email@hidden>
    • Re: Why multi-threading ?
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: Why multi-threading ? (From: Dietrich Epp <email@hidden>)

  • Prev by Date: Re: State of instance variables defined at instantiation?
  • Next by Date: Re: Using DO from daemon
  • Previous by thread: Re: Why multi-threading ?
  • Next by thread: Re: Why multi-threading ?
  • Index(es):
    • Date
    • Thread